(function(){
var Me=Class.extends("core.Box",null);
Me.proto.id=null
Me.proto.name=null
Me.proto.removed=false
Me.proto.children=[]
Me.proto.listeners=[]
Me.proto.changed=false
Me.proto.enabled=true
Me.proto.subEnabled=true
Me.proto.visible=true
Me.proto.relative=0
Me.proto.absolute=false
Me.proto.alpha=1
Me.proto.rotation=0
Me.proto.gray=false
Me.proto.x=0
Me.proto.y=0
Me.proto.w=0
Me.proto.h=0
Me.proto.scaleX=1
Me.proto.scaleY=1
Me.proto.pivot=null
Me.proto.bg=null
Me.proto.bgDashed=false
Me.proto.mask=false
Me.proto.scroll=false
Me.proto.padding=0
Me.proto.shadow=null
Me.proto.dimTo=null
Me.proto.borderSize=[0,0]
 
Me.proto.__ctor=function(param){
 BoxAid.init()
 if(!this.div){
 this.div=document.createElement("div")
 this.div.className="__box"
 this.div.box=this
 this.removed=false
 }
 else{
 this.div.style.cssText=""
 while(this.div.childNodes.length>0){
 this.div.removeChild(this.div.childNodes[0])
 }
 }
 BoxAid.birthNode.appendChild(this.div)
 this.__isBox=true
 if(this.__class==Main){
 G.main=this
 this.setMask(true)
 this.setSize(G.w,G.h)
 G.stage.addChild(this)
 }
 if(this.__class==Box&&param){
 this.set(param)
 }
 if(this.onPress) this.addListener(Evt.PRESS,this,this.onPress)
 if(this.onRelease) this.addListener(Evt.RELEASE,this,this.onRelease)
 if(this.onClick) this.addListener(Evt.CLICK,this,this.onClick)
 if(this.onButtonPreClick) this.addListener(Evt.BUTTON_CLICK,this,this.onButtonPreClick)
 if(this.onButtonClick) this.addListener(Evt.BUTTON_CLICK,this,this.onButtonClick)
 if(this.onChange) this.addListener(Evt.CHANGE,this,this.onChange)
 if(this.onKeyDown) G.stage.addListener(Evt.KEY_DOWN,this,this.onKeyDown)
 }
Me.proto.set=function(param){
 for(var k in param){
 if(k=="x"||k=="y"||k=="w"||k=="h"||k=="pos"||k=="size"||k=="bg") continue
 var func=this["set"+k.charAt(0).toUpperCase()+k.slice(1)]
 var child=this[k]
 if(typeof(func)=="function"){
 func.call(this,param[k])
 }
 else if(child&&typeof(child)=="object"&&child.__isBox){
 child.set(param[k])
 }
 else{
 this[k]=param[k]
 }
 }
 if(param.w!=null) this.setW(param.w)
 if(param.h!=null) this.setH(param.h)
 if(param.size) this.setSize.apply(this,param.size)
 if(param.x!=null) this.setX(param.x)
 if(param.y!=null) this.setY(param.y)
 if(param.pos) this.setPos.apply(this,param.pos)
 if(param.bg) this.setBg(param.bg)
 }
Me.proto.addChild=function(child,index){if(index==null){index=-1}
 this.scrollChangeSelf()
 if(is(Array,child)){
 return BoxAid.addAML(this,child)
 }
 else if(is(String,child)){
 child=Class.new(Img,child)
 }
 else if(child.__isClass){
 child=Class.new(child)
 }
 else if(!child.__isBox){
 var param=child
 child=this.addChild(Class.new(Box))
 child.set(param)
 if(param.dim) this[param.dim]=child
 }
 if(!this.subEnabled) child.setEnabled(false)
 if(this.relative>0){
 if(child.visible&&!child.absolute){
 child.div.style.position="static"
 }
 if(this.relative>1){
 child.div.style.display="inline-block"
 }
 if(this.relative==1&&child.w==0){
 child.setW("f")
 }
 }
 if(child.parent){
 var n=child.parent.children.indexOf(child)
 child.parent.children.splice(n,1)
 }
 if(index==-1||index>=this.children.length){
 this.div.appendChild(child.div)
 this.children.push(child)
 }
 else{
 var child2=this.children[index]
 this.div.insertBefore(child.div,child2.div)
 this.children.splice(index,0,child)
 }
 child.parent=this
 child.onAdded()
 return child
 }
Me.proto.remove=function(){
 if(this.parent) this.parent.scrollChangeSelf()
 this.remove2(this)
 for(var i=G.stage.listeners.length-1;i>=0;i--){
 var arr=G.stage.listeners[i]
 var caller=arr[2]
 if(caller.__isBox&&caller.removed){
 G.stage.div.removeEventListener(arr[0],arr[1])
 G.stage.listeners.splice(i,1)
 }
 }
 for(var i=GAid.laterCalls.length-1;i>=0;i--){
 var obj=GAid.laterCalls[i]
 var caller=obj.foo[0]
 if(caller.__isBox&&caller.removed){
 obj.status=2
 }
 }
 }
Me.proto.remove2=function(box){
 box.removed=true
 box.div.style.cssText=""
 if(box.onRemove) box.onRemove.apply(box)
 var pools=Class.poolHash[box.__className]
 if(!pools) pools=Class.poolHash[box.__className]=[]
 pools.push(box)
 
 while(box.listeners&&box.listeners.length>0){
 var arr=box.listeners.shift()
 box.div.removeEventListener(arr[0],arr[1])
 }
 if(box.parent){
 var n=box.parent.children.indexOf(box)
 box.parent.children.splice(n,1)
 box.parent.div.removeChild(box.div)
 box.parent=null
 }
 while(box.children.length>0){
 var child=box.children[0]
 this.remove2(child)
 }
 }
Me.proto.removeChildren=function(){
 while(this.children.length>0){
 var child=this.children[0]
 child.remove()
 }
 }
Me.proto.getChild=function(name){
 for(var i=0;i<this.children.length;i++){
 var child=this.children[i]
 if(child.id==name) return child
 if(child.name==name) return child
 }
 return null
 }
Me.proto.addListener=function(type,caller,func){
 if(typeof(caller)=="function"){
 func=caller
 caller=null
 }
 var evtFunc=function(evt){
 if(evt.type=="click"&&!evt.enabled) return
 func.call(caller,evt)
 }
 this.div.addEventListener(type,evtFunc)
 this.listeners.push([type,evtFunc,caller])
 }
Me.proto.dispatchEvent=function(evt){
 this.div.dispatchEvent(evt)
 }
Me.proto.setPos=function(x,y,w,h){
 if(w!=null||h!=null){
 this.setSize(w||this.w,h||this.h)
 }
 if(x!=null) this.setX(x,false)
 if(y!=null) this.setY(y,false)
 this.resetTransform()
 }
Me.proto.setSize=function(w,h){
 if(w==null) w=this.w
 if(h==null) h=this.h
 this.__w=w
 if(typeof(w)=="string"&&w.charAt(0)=="f"){
 w=eval(w.replace("f",this.getParentW()))
 }
 this.w=w
 this.div.style.width=w==0?"auto":w+"px"
 
 this.__h=h
 if(typeof(h)=="string"&&h.charAt(0)=="f"){
 h=eval(h.replace("f",this.getParentH()))
 }
 this.h=h
 if(this.mask||this.relative==0||this.scroll){
 this.div.style.height=h==0?"auto":h+"px"
 this.div.style.minHeight="auto"
 }
 else{
 this.div.style.height="auto"
 this.div.style.minHeight=h==0?"auto":h+"px"
 }
 if(this.__pivot=="c"&&this.w>0&&this.h>0){
 this.setPivot("c")
 }
 if(this.parent) this.parent.scrollChangeSelf()
 }
Me.proto.contains=function(target){
 while(target){
 if(this==target) return true
 target=target.parent
 }
 return false
 }
Me.proto.inScroll=function(){
 var box=this
 while(box&&box!=G.stage){
 if(box.scroll) return true
 box=box.parent
 }
 return false
 }
Me.proto.transit=function(param,doBack){
 if(!param){
 this.div.style[G.toCssKey("Transition")]="none"
 this.doTransit=null
 return
 }
 this.doTransit=doBack
 var ease=param.ease||0
 var time=param.time||300
 var delay=param.delay||0
 delete param.ease
 delete param.time
 delete param.delay
 var easeExpr="linear"
 if(ease==1) easeExpr="cubic-bezier(0.215, 0.61, 0.355, 1)"
 if(ease==2) easeExpr="cubic-bezier(0.55, 0.055, 0.675, 0.19)"
 if(ease==3) easeExpr="cubic-bezier(0.175,0.885,0.32,1.275)"
 if(ease==4) easeExpr="cubic-bezier(0.6,-0.28,0.735,0.045)"
 var param2
 for(var k in param){
 var v=param[k]
 if(!is(Array,v)) continue
 if(!param2) param2={}
 param2[k]=v[0]
 param[k]=v[1]
 }
 if(param2) this.set(param2)
 if(this.scaleX==0) this.setScale(0.01)
 this.div.scrollTop=this.div.scrollTop
 this.div.style[G.toCssKey("Transition")]="all "+(time/1000)+"s "+easeExpr+" "+(delay/1000)+"s"
 this.set(param)
 if(this.scaleX==0) this.setScale(0.01)
 callLater([this,this.transitEnd],time+delay+50)
 }
Me.proto.transitEnd=function(){
 this.div.style[G.toCssKey("Transition")]="none"
 call(this.doTransit)
 }
Me.proto.hitTest=function(x,y){
 var r=this.div.getBoundingClientRect()
 var rx=r.left/G.scale
 var ry=r.top/G.scale
 return x>rx&&x<rx+this.w&&y>ry&&y<ry+this.h
 }
Me.proto.startDrag=function(range,doDrag,useSlide,bounceSize){if(doDrag==null){doDrag=null};if(useSlide==null){useSlide=true};if(bounceSize==null){bounceSize=0}
 Drag.start(this,range,doDrag,useSlide,bounceSize)
 }
Me.proto.resetSelf=function(){
 }
Me.proto.resetTransform=function(){
 var px=!this.pivot?0:this.pivot[0]
 var py=!this.pivot?0:this.pivot[1]
 if(px!=0||py!=0){
 this.div.style[G.toCssKey("TransformOrigin")]=px+"px "+py+"px"
 }
 var x=this.x-px
 var y=this.y-py
 var str=""
 if(G.platform==1||x!=0||y!=0) str+="translate3d("+x+"px,"+y+"px,0) "
 if(this.scaleX!=1||this.scaleY!=1) str+="scale("+this.scaleX+","+this.scaleY+") "
 if(this.rotation!=0) str+="rotate("+this.rotation+"deg)"
 this.div.style[G.toCssKey("Transform")]=str
 }
Me.proto.changeSelf=function(){
 if(!GAid.changedHash) GAid.changedHash={}
 GAid.changedHash[this.__id]=this
 }
Me.proto.scrollChangeSelf=function(){
 if(!this.scroll) return
 if(!GAid.scrollChangedHash) GAid.scrollChangedHash={}
 GAid.scrollChangedHash[this.__id]=this
 }
Me.proto.getClientW=function(){
 return this.div.clientWidth
 }
Me.proto.getClientH=function(){
 return this.div.clientHeight
 }
Me.proto.getAbsX=function(){
 return this.div.getBoundingClientRect().left/G.scale
 }
Me.proto.getAbsY=function(){
 return this.div.getBoundingClientRect().top/G.scale
 }
Me.proto.setEnabled=function(v){
 this.enabled=v
 this.div.style.pointerEvents=v?"auto":"none"
 }
Me.proto.setVisible=function(v){
 this.visible=v
 if(v){
 this.div.style.visibility=""
 if(this.parent&&this.parent.relative){
 this.div.style.position="static"
 this.div.style.top="auto"
 }
 else{
 this.div.style.position="absolute"
 }
 }
 else{
 this.div.style.visibility="hidden"
 this.div.style.position="absolute"
 if(this.parent&&this.parent.relative) this.div.style.top="0"
 }
 if(this.parent) this.parent.scrollChangeSelf()
 }
Me.proto.getDepth=function(){
 if(!this.parent) return -1
 for(var i=0;i<this.parent.children.length;i++){
 if(this.parent.children[i]==this) return i
 }
 return -1
 }
Me.proto.getParentW=function(){
 return this.parent?(this.parent.w==0?this.parent.children[0].w:this.parent.w)-this.parent.borderSize[0]:G.main.w
 }
Me.proto.getParentH=function(){
 return this.parent?(this.parent.h==0?this.parent.children[0].h:this.parent.h)-this.parent.borderSize[1]:G.main.h
 }
Me.proto.setX=function(v,change){if(change==null){change=true}
 this.__x=v
 var type=typeof(v)=="string"?v.slice(0,1):null
 if(type=="c"){
 if(this.w==0) this.w=this.getClientW()
 var w=this.pivot?0:this.w*this.scaleX
 v=(this.getParentW()-w)/2+int(v.slice(1))
 }
 else if(type=="r"){
 if(this.w==0) this.w=this.getClientW()
 v=this.getParentW()-this.w*this.scaleX+int(v.slice(1))
 }
 else if(type=="f"){
 v=eval(v.replace("f",this.getParentW()))
 }
 else if(type=="+"&&this.parent&&this.parent.relative==0){
 var depth=this.getDepth()
 if(depth>0){
 var box=this.parent.children[depth-1]
 if(box.w==0) box.w=box.getClientW()
 v=box.x+box.w*this.scaleX+int(v.slice(1))
 this.y=box.y
 }
 else{
 v=0
 }
 }
 if(this.parent&&this.parent.relative>0){
 this.div.style.marginLeft=v+"px"
 v=0
 }
 this.x=v
 if(change) this.resetTransform()
 }
Me.proto.setY=function(v,change){if(change==null){change=true}
 this.__y=v
 var type=typeof(v)=="string"?v.slice(0,1):null
 if(type=="c"){
 if(this.h==0) this.h=this.getClientH()
 var h=this.pivot?0:this.h*this.scaleX
 v=(this.getParentH()-h)/2+int(v.slice(1))
 }
 else if(type=="b"){
 if(this.h==0) this.h=this.getClientH()
 v=this.getParentH()-this.h*this.scaleY+int(v.slice(1))
 }
 else if(type=="+"&&this.parent&&this.parent.relative==0){
 var depth=this.getDepth()
 if(depth>0){
 var box=this.parent.children[depth-1]
 if(box.h==0) box.h=box.getClientH()
 v=box.y+box.h*this.scaleY+int(v.slice(1))
 }
 else{
 v=0
 }
 }
 if(this.parent&&this.parent.relative>0){
 this.div.style.marginTop=v
 v=0
 }
 this.y=v
 if(change) this.resetTransform()
 }
Me.proto.setW=function(v){
 this.setSize(v,this.h)
 }
Me.proto.setH=function(v){
 this.setSize(this.w,v)
 }
Me.proto.setAlpha=function(v){
 this.alpha=v
 this.div.style.opacity=v
 }
Me.proto.setScale=function(v){
 this.scaleX=v
 this.scaleY=v
 this.resetTransform()
 }
Me.proto.setScaleX=function(v){
 this.scaleX=v
 this.resetTransform()
 }
Me.proto.setScaleY=function(v){
 this.scaleY=v
 this.resetTransform()
 }
Me.proto.setRotation=function(v){
 this.rotation=v
 this.resetTransform()
 }
Me.proto.setPivot=function(v){
 this.__pivot=v
 if(v=="c"){
 if(this.w==0) return
 v=[this.w/2,this.h/2]
 }
 this.__pivot=v
 this.pivot=v
 this.resetTransform()
 }
Me.proto.setBg=function(v){
 this.bg=v
 if(is(Array,v)&&is(String,v[2])){
 var arr=G.bgStyle[v[2]]
 if(arr){
 var w=this.w
 var h=this.h
 for(var i=0;i<arr.length;i++){
 var a=arr[i]
 if(a){
 a=a.slice(0)
 for(var j=0;j<a.length;j++){
 a[j]=a[j]*[j%2==0?w:h]/100
 }
 }
 v[3+i]=a
 }
 }
 BoxAid.drawBgShape(this,v)
 return
 }
 this.borderSize[0]=0
 this.borderSize[1]=0
 var a=["none","none","none","none","none","none","none","none","none"]
 if(is(String,v)){
 a[0]=!v?"none":G.toColor(v)
 }
 else if(is(Array,v)){
 if(is(Array,v[0])){
 var c1=G.toColor(v[0][0])
 var c2=G.toColor(v[0][1])
 var t=v[0][2]||1
 var n=(v[0][3]||1)*100
 var angleStr=(n/2)+"% 0,"+(n/2)+"% "+n+"%"
 if(t==2) angleStr="0 "+n+"%,"+n+"% 0"
 if(t==3) angleStr="0 "+(n/2)+"%,"+n+"% "+(n/2)+"%"
 if(t==4) angleStr=n+"% "+n+"%,0 0"
 a[0]=G.toCssKey("gradient")+"(linear,"+angleStr+",from("+c1+"),to("+c2+"))"
 }
 else{
 a[0]=!v?"none":G.toColor(v[0])
 }
 for(var i=0;i<4;i++){
 var s=is(Array,v[1])?v[1][i]:v[1]
 if(!s) continue
 var n=s.indexOf("#")
 var c=n==0?s:s.slice(n)
 var w=n==0?1:s.slice(0,n)
 this.borderSize[i>1?0:1]+=int(w)
 a[i+1]=w+"px "+(this.bgDashed?"dashed":"solid")+" "+G.toColor(c)
 }
 for(var i=0;i<4;i++){
 var n=is(Array,v[2])?v[2][i]:v[2]
 if(!n) continue
 a[i+5]=n+"px"
 }
 }
 if(!is(Img,this)) this.div.style.background=a[0]
 this.div.style.borderTop=a[1]
 this.div.style.borderBottom=a[2]
 this.div.style.borderLeft=a[3]
 this.div.style.borderRight=a[4]
 this.div.style[G.toCssKey("BorderTopLeftRadius")]=a[5]
 this.div.style[G.toCssKey("BorderTopRightRadius")]=a[6]
 this.div.style[G.toCssKey("BorderBottomLeftRadius")]=a[7]
 this.div.style[G.toCssKey("BorderBottomRightRadius")]=a[8]
 }
Me.proto.setBgDashed=function(v){
 this.bgDashed=v
 if(this.bg) this.setBg(this.bg)
 }
Me.proto.setGray=function(v){
 this.gray=v
 this.div.style[G.toCssKey("Filter")]=v?"grayscale(100%)":"none"
 }
Me.proto.setMask=function(v){
 this.mask=v
 this.div.style.overflow=v?"hidden":"visible"
 this.setSize(this.w,this.h)
 }
Me.proto.setRelative=function(v){
 this.relative=v
 this.div.style.textAlign=v<=2?"left":(v==3?"center":"right")
 this.setSize(this.w,this.h)
 }
Me.proto.setAbsolute=function(v){
 this.absolute=v
 }
Me.proto.setScroll=function(v){
 this.scroll=v
 this.div.scroll=v
 this.div.style.overflowY=v?"auto":"visible"
 this.div.style.overflowX=v?"hidden":"visible"
 }
Me.proto.setPadding=function(v){
 this.padding=v
 var isArr=is(Array,v)
 this.div.style.paddingTop=isArr?int(v[0])+"px":v+"px"
 this.div.style.paddingBottom=isArr?int(v[1])+"px":v+"px"
 this.div.style.paddingLeft=isArr?int(v[2])+"px":v+"px"
 this.div.style.paddingRight=isArr?int(v[3])+"px":v+"px"
 }
Me.proto.setShadow=function(v){
 this.shadow=v
 var css="none"
 if(is(Array,v)){
 css=v[0]+"px "+v[1]+"px "+v[2]+"px "+G.toColor(v[3])
 if(v[4]) css+=" inset"
 }
 else if(v){
 css="5px 5px 5px "+G.toColor("#4000")
 }
 this.div.style.boxShadow=css
 }
Me.proto.onAdded=function(){
 }
})();
(function(){
var Me=Class.extends("Main",Box);
Me.proto.__ctor=function(){
 
 
 
 Class.new(Guide,13)
 
 }
})();
(function(){
var Me=Class.extends("components.SlideBar",Box);
Me.proto.index=0
Me.proto.dotColor=["#4fff","#cfff"]
Me.proto.body=null
Me.proto.dotBox=null
Me.proto.tween=null
Me.proto.startTime=null
Me.proto.__ctor=function(){
 this.startTime=G.now
 this.setSize("f",270)
 this.body=this.addChild(Box)
 this.body.setW("f")
 this.dotBox=this.addChild(Box)
 this.changeSelf()
 }
Me.proto.resetSelf=function(){
 for(var i=this.children.length-1;i>=0;i--){
 var box=this.children[i]
 if(box==this.body||box==this.dotBox) continue
 box.setSize("f",this.h)
 this.body.addChild(box,0)
 }
 var count=this.body.children.length
 if(count==0) return
 var index=this.index
 var x=this.body.x
 if(x<=-G.w){
 index++
 x+=G.w
 if(Drag.target==this.body) Drag.fromPos.x+=G.w
 if(index>=count) index=0
 }
 else if(x>=G.w){
 index--
 x-=G.w
 if(Drag.target==this.body) Drag.fromPos.x-=G.w
 if(index<=-1) index=count-1
 }
 this.index=index
 this.body.setX(x)
 var index2=x<=0?index+1:index-1
 if(index2<=-1) index2=count-1
 if(index2>=count) index2=0
 for(var i=0;i<count;i++){
 var cell=this.body.children[i]
 cell.setVisible(i==index||i==index2)
 }
 var cell=this.body.children[index]
 cell.setX(0)
 var cell2=this.body.children[index2]
 var dir=(index2==index+1)?1:-1
 if(index==count-1&&index2==0) dir=1
 if(count==2&&this.body.x>0){
 dir=-1
 }
 if(cell!=cell2) cell2.setX(dir*G.w)
 
 var x=0
 for(var i=0;i<count;i++){
 var dot=this.dotBox.children[i]
 if(!dot){
 dot=this.dotBox.addChild(Class.new(Box,{w:16,h:16,bg:["#fff",,8]}))
 }
 var c=this.dotColor[this.index==i?1:0]
 dot.setBg([c,,8])
 dot.setX(x)
 x+=dot.w+10
 }
 var w=x-10
 this.dotBox.setX((G.w-w)/2)
 this.dotBox.setY(this.h-40)
 }
Me.proto.play=function(dir){
 if(this.body.children.length<=1) return
 this.startTime=G.now
 var count=this.body.children.length
 var index=this.index+dir
 if(index<=-1) index=count-1
 if(index>=count) index=0
 this.body.transit({x:-dir*G.w,ease:1},[this,this.play2,index])
 }
Me.proto.play2=function(index){
 this.index=index
 this.body.setX(0)
 this.changeSelf()
 }
Me.proto.onDrag=function(finish){
 if(!finish){
 this.changeSelf()
 return
 }
 var dir=0
 var x=this.body.x
 if(x<0){
 if(-x>60) dir=1
 }
 else{
 if(x>60) dir=-1
 }
 this.play(dir)
 }
Me.proto.onPress=function(){
 if(this.body.children.length<=1) return
 G.isPress=false
 var x=this.body.x
 this.body.transit(null)
 this.body.startDrag([x-2*G.w,0,x+4*G.w,0],[this,this.onDrag],false)
 }
Me.proto.onClick=function(){
 this.dispatchEvent(G.newEvent(Evt.CHANGE))
 if(this.parent==G.stage){
 this.remove()
 }
 }
})();
(function(){
var Me=Class.extends("components.SoundTape",Box);
Me.proto.playing=false
Me.proto.audio=null
Me.proto.url=null
Me.proto.frame=0
Me.proto.ring2=null
Me.proto.ring3=null
Me.proto.label=null
Me.proto.frameTime=0
Me.proto.__ctor=function(url,duration,flip){if(duration==null){duration=60};if(flip==null){flip=false}
 this.url=url
 var w=150+250*(Math.min(duration,60)/60)
 this.setSize(w,72)
 this.setBg(["#2eb0ff","#0290da",!flip?[,36,36,36]:[36,,36,36]])
 this.addChild([
 [{pos:[34,34,4,4],bg:["#fff",,2]}],
 [{dim:"ring2",pos:[36,36,18,18],mask:true,rotation:-45},[{pos:[-9,-9,18,18],bg:[,"2#fff",9]}]],
 [{dim:"ring3",pos:[36,36,32,32],mask:true,rotation:-45},[{pos:[-16,-16,32,32],bg:[,"2#fff",16]}]],
 [[duration+"\"","#fff"],{dim:"label",pos:[65,"c"]}],
 ])
 }
Me.proto.setFrame=function(f){
 if(f>=3) f=0
 this.frame=f
 this.ring2.setVisible(this.frame==0||this.frame==2)
 this.ring3.setVisible(this.frame==0)
 }
Me.proto.onClick=function(){
 if(!this.audio){
 this.audio=document.createElement("audio")
 }
 this.playing=!this.playing
 if(this.playing){
 this.audio.src=this.url
 this.audio.play()
 }
 else{
 this.audio.pause()
 }
 }
Me.proto.onFrame=function(){
 if(this.playing&&this.audio.paused){
 this.playing=false
 }
 if(G.now-this.frameTime>300&&(this.playing||this.frame!=0)){
 this.frameTime=G.now
 this.setFrame(++this.frame)
 }
 }
})();
(function(){
var Me=Class.extends("components.TabBar",Box);
Me.fromIndex=-1
Me.proto.body=null
Me.proto.line=null
Me.proto.index=0
Me.proto.items=null
Me.proto.color=["#333","#2b2"]
Me.proto.__ctor=function(items,index){if(index==null){index=0}
 this.set({w:"f",h:70,bg:["#fff",[,"#ddd"]]})
 this.addChild([
 [{dim:"body",enabled:false}],
 [{dim:"line",h:2,y:68,enabled:false}]
 ])
 this.items=items
 this.setIndex(index)
 }
Me.proto.resetSelf=function(){
 this.body.setSize("f","f")
 var count=this.items.length
 var cellW=int(this.w/count)
 for(var i=0;i<count;i++){
 var text=this.items[i]
 var label=this.body.children[i]
 if(!label){
 var bg=i<count-1?[,[,,,"#ccc"]]:null
 label=this.body.addChild([
 [[text],{pos:[i*cellW,"c",cellW,30],lineH:1,align:"c",bg:bg}]
 ])
 }
 label.setColor(this.color[this.index==i?1:0])
 }
 while(this.body.children.length>count){
 var child=this.body.children[this.body.children.length-1]
 child.remove()
 }
 this.line.setW(cellW)
 this.line.setBg(this.color[1])
 if(Me.fromIndex>-1){
 this.line.setX(Me.fromIndex*cellW)
 this.line.transit({ease:1})
 Me.fromIndex=-1
 }
 this.line.setX(this.index*cellW)
 }
Me.proto.setSize=function(w,h){
 Box.proto.setSize.call(this,w,h)
 this.changeSelf()
 }
Me.proto.setItems=function(v){
 this.items=v
 this.changeSelf()
 }
Me.proto.setColor=function(v){
 this.color=v
 this.changeSelf()
 }
Me.proto.setIndex=function(v){
 this.index=v
 this.changeSelf()
 }
Me.proto.onClick=function(){
 var index=int((G.x-this.getAbsX())/(this.w/this.items.length))
 if(index==this.index) return
 Me.fromIndex=this.index
 this.line.transit({ease:1})
 this.setIndex(index)
 this.dispatchEvent(G.newEvent(Evt.CHANGE))
 if(this.stage) Me.fromIndex=-1
 }
})();
(function(){
var Me=Class.extends("components.TimePicker",Box);
Me.proto.hour=null
Me.proto.minute=null
Me.proto.partList=null
Me.proto.hourList=null
Me.proto.minuteList=null
Me.proto.moveType=0
Me.proto.pressY=null
Me.proto.limits=null
Me.proto.limitTime=0
Me.proto.__ctor=function(hour,minute,limits){if(hour==null){hour=12};if(minute==null){minute=0};if(limits==null){limits=null}
 this.hour=hour
 this.minute=minute
 this.limits=limits
 this.setSize("f",320)
 this.addChild([
 [{pos:[0,120,"f",80],bg:[,["#eee","#eee"]]}],
 [{dim:"partList",pos:[130,0,130,"f"]}],
 [{dim:"hourList",pos:["+",0,130,"f"],bg2:"#4000"}],
 [{dim:"minuteList",pos:["+",0,130,"f"]}],
 ])
 var arr=[[25,22,0.4],[40,24,0.5],[55,30,0.6],[80,34,1],[55,30,0.6],[40,24,0.5],[25,22,0.4]]
 var y=0
 for(var i=0;i<7;i++){
 var a=arr[i]
 for(var j=0;j<3;j++){
 var box=this.children[j+1]
 var scaleY=a[2]==0.4?0.8:(a[2]==0.5?0.9:1)
 box.addChild([
 [Label,{pos:[0,y,130,a[0]],fontSize:a[1],alpha:a[2],align:"c",scaleY:scaleY,lineH:a[0]}]
 ])
 }
 y+=a[0]
 }
 this.changeSelf()
 }
Me.proto.resetSelf=function(){
 this.partList.children[2].setText(this.hour<=12?"":"上午")
 this.partList.children[3].setText(this.hour<=12?"上午":"下午")
 this.partList.children[4].setText(this.hour<=12?"下午":"")
 for(var i=0;i<7;i++){
 var n=this.hour+i-3
 if(n<=0) n+=12
 if(n>12) n-=12
 if(n>12) n-=12
 var label=this.hourList.children[i]
 label.setText(n)
 }
 for(var i=0;i<7;i++){
 var n=this.minute+(i-3)*5
 if(n<0) n+=60
 if(n>=60) n-=60
 var label=this.minuteList.children[i]
 label.setText(n)
 }
 }
Me.proto.onPress=function(){
 this.moveType=int(G.x/130)
 if(this.moveType>=4) this.moveType=0
 this.pressY=G.y
 }
Me.proto.onRelease=function(){
 this.moveType=0
 }
Me.proto.onFrame=function(){
 if(this.moveType>0&&Math.abs(G.y-this.pressY)>20){
 var dir=G.y>this.pressY?1:-1
 this.pressY=G.y
 if(this.moveType==1){
 if(this.hour<=12&&dir==-1) this.hour+=12
 if(this.hour>12&&dir==1) this.hour-=12
 }
 if(this.moveType==2){
 this.hour-=dir
 if(this.hour<=0) this.hour+=24
 if(this.hour>24) this.hour-=24
 }
 if(this.moveType==3){
 this.minute-=dir*5
 if(this.minute<0) this.minute+=60
 if(this.minute>=60) this.minute-=60
 }
 this.changeSelf()
 }
 if(!G.isPress){
 if(this.limits&&G.now-this.limitTime>50){
 this.limitTime=G.now
 var hour=this.hour
 var minute=this.minute
 if(hour<this.limits[0]){
 hour++
 }
 if(hour==this.limits[0]&&minute<this.limits[1]){
 minute+=5
 }
 if(this.limits.length==4&&hour>this.limits[2]){
 hour--
 }
 if(this.limits.length==4&&hour==this.limits[2]&&minute>this.limits[3]){
 minute-=5
 }
 if(hour!=this.hour||minute!=this.minute){
 this.hour=hour
 this.minute=minute
 this.changeSelf()
 }
 }
 }
 }
})();
(function(){
var Me=Class.extends("core.BoxAid",null);
Me.birthNode=null
Me.inited=false
Me.headStyle=null
Me.init=function(){
 if(Me.inited) return
 Me.inited=true
 Me.headStyle=document.createElement("style")
 document.head.appendChild(Me.headStyle)
 Me.headStyle.sheet.insertRule(
 "div.__box{position:absolute;vertical-align:middle;display:block;"
 +"font-family:"+(G.os==1?"Microsoft Yahei,PingFangSC-Light":"")+";"
 +"background-repeat:no-repeat;"
 +G.toCssKey("user-select")+":none;"
 +G.toCssKey("transform-origin")+":0 0;"+G.toCssKey("box-sizing")+":border-box;"
 +G.toCssKey("tap-highlight-color")+":rgba(0,0,0,0);"+G.toCssKey("overflow-scrolling")+":touch;"
 +G.toCssKey("touch-callout")+":none}",
 0
 )
 if(G.os==3){
 Me.headStyle.sheet.insertRule("div::"+G.toCssKey("scrollbar")+"{width:0px}",0)
 Me.headStyle.sheet.insertRule("input::"+G.toCssKey("input-placeholder")+"{color:#a0a0a0}",0)
 }
 
 document.body.style.cssText="margin:0;overflow:hidden;"+G.toCssKey("text-size-adjust")+":100% !important"
 
 Me.birthNode=document.createElement("div")
 document.body.appendChild(Me.birthNode)
 Me.birthNode.style.visibility="hidden"
 
 G.canvas=document.createElement("canvas")
 G.bgStyle["star"]=[[50,0],[38,38],[0,38],[31,60],[19,96],[50,75],[81,96],[70,60],[100,38],[62,38],[50,0]]
 }
Me.addAML=function(caller,items){
 var queues=[[items,null]]
 var resizeBoxs=[]
 var firstBox
 while(queues.length>0){
 var itemArr=queues.pop()
 var arr=itemArr[0]
 if(arr[0]==null) continue
 var parentArr=itemArr[1]
 if(!parentArr){
 arr.unshift(caller)
 }
 var args=null
 if(typeof(arr[0])=="object"&&!is(Array,arr[0])&&!arr[0].__isBox){
 args=arr[0]
 arr[0]=Class.new(Box)
 }
 if(typeof(arr[1])=="object"&&!is(Array,arr[1])&&arr[1].doif==null){
 args=arr[1]
 }
 if(is(String,arr[0])){
 arr[0]=Class.new(Img,arr[0])
 }
 else if(is(Array,arr[0])){
 arr[0]=Class.new(Label,arr[0][0],arr[0][1],arr[0][2])
 }
 else if(arr[0].__isClass){
 if(args&&args.idx) Class.test=true
 arr[0]=Class.new(arr[0])
 Class.test=false
 }
 var box=arr[0]
 if(box!=caller&&!firstBox) firstBox=box
 for(var i=1;i<arr.length;i++){
 var subArr=arr[i]
 if(subArr.hasOwnProperty("doif")&&!subArr.doif){
 i++
 }
 if(!is(Array,subArr)) continue
 queues.unshift([subArr,itemArr])
 }
 var hasSpecial=false
 if(args){
 if(args.style){
 var style=G.style[args.style]
 for(var k in style){
 if(args[k]==null) args[k]=style[k]
 }
 }
 for(var k in args){
 var v=args[k]
 if(k=="dim"){
 var dimTo=caller.dimTo||caller
 dimTo[v]=box
 }
 else if(k=="x"||k=="y"||k=="w"||k=="h"||k=="pos"||k=="size"||k=="bg"){
 hasSpecial=true
 }
 else{
 var func=box["set"+k.charAt(0).toUpperCase()+k.slice(1)]
 if(typeof(func)=="function"){
 func.call(box,args[k])
 }
 else{
 box[k]=args[k]
 }
 }
 }
 }
 if(parentArr){
 var parentBox=parentArr[0][0]
 parentBox.addChild(box)
 }
 if(parentBox&&parentBox.relative==1&&box.__class==Box&&box.w==0&&args&&!args.w){
 box.setW("f")
 }
 if(hasSpecial){
 if(args.w!=null||args.h!=null){
 box.setSize(args.w==null?box._w:args.w,args.h==null?box._h:args.h)
 }
 if(args.size!=null) box.setSize.apply(box,args.size)
 if(args.x!=null) box.setX(args.x)
 if(args.y!=null) box.setY(args.y)
 if(args.pos!=null) box.setPos.apply(box,args.pos)
 if(args.bg!=null) box.setBg(args.bg)
 }
 if(box._w==0) resizeBoxs.unshift(box)
 }
 for(var i=0;i<resizeBoxs.length;i++){
 var box=resizeBoxs[i]
 var child=box.children[0]
 if(!child||child.w==0) continue
 box.setSize(child.w,child.h)
 }
 return firstBox
 }
Me.drawBgShape=function(caller,arr){
 G.canvas.width=caller.w
 G.canvas.height=caller.h
 var sp=[]
 var ctx=G.canvas.getContext("2d")
 ctx.clearRect(0,0,caller.w,caller.h)
 ctx.beginPath()
 for(var i=2;i<arr.length;i++){
 var a=arr[i]
 if(i==2||a==0){
 a=arr[i-1]
 if(is(Array,a)&&sp[0]==a[0]&&sp[1]==a[1]){
 ctx.closePath()
 }
 i++
 a=arr[i]
 if(!a) continue
 sp[0]=a[0]
 sp[1]=a[1]
 if(is(Array,a)) ctx.moveTo(a[0],a[1])
 continue
 }
 if(a==1) continue
 if(is(Array,a)){
 ctx.lineTo(a[0],a[1])
 continue
 }
 var t=a
 var x1=arr[i-1][0]
 var y1=arr[i-1][1]
 if(!is(Array,arr[i+1])) continue
 var x2=arr[i+1][0]
 var y2=arr[i+1][1]
 if(t==2||t==3){
 var r=(Math.abs(x2-x1)+Math.abs(y2-y1))/2
 if(y1==y2){
 ctx.arcTo(x1,t==2?y1-r:y1+r,(x2+x1)/2,t==2?y2-r:y2+r,r)
 ctx.arcTo(x2,t==2?y1-r:y1+r,x2,y2,r)
 }
 else if(x1==x2){
 ctx.arcTo(t==2?x1-r:x1+r,y1,t==2?x1-r:x1+r,(y1+y2)/2,r)
 ctx.arcTo(t==2?x1-r:x1+r,y2,x2,y2,r)
 }
 else{
 if(Math.abs(x2-x1)>Math.abs(y2-y1)){
 r=Math.abs(y2-y1)
 var x3=x2+(x2>x1?-1:1)*r
 ctx.lineTo(x3,y1)
 x1=x3
 }
 else if(Math.abs(x2-x1)<Math.abs(y2-y1)){
 r=Math.abs(x2-x1)
 var y3=y2+(y2>y1?-1:1)*r
 ctx.lineTo(x1,y3)
 y1=y3
 }
 ctx.arcTo(t==2?x2:x1,t==2?y1:y2,x2,y2,r)
 }
 i++
 }
 else if(t==4){
 if(!is(Array,arr[i+2])) continue
 var x3=arr[i+2][0]
 var y3=arr[i+2][1]
 var e=((x1*x1-x2*x2)+(y1*y1-y2*y2))/2
 var f=((x1*x1-x3*x3)+(y1*y1-y3*y3))/2
 var x0=-((y1-y3)*e-(y1-y2)*f)/((y1-y2)*(x1-x3)-(x1-x2)*(y1-y3))
 var y0=-((x1-x2)*f-(x1-x3)*e)/((y1-y2)*(x1-x3)-(x1-x2)*(y1-y3))
 var r=Math.distance(x0,y0,x1,y1)
 var ag1=Math.atan2(y1-y0,x1-x0)*180/Math.PI
 var ag2=Math.atan2(y2-y0,x2-x0)*180/Math.PI
 var ag3=Math.atan2(y3-y0,x3-x0)*180/Math.PI
 if(ag1<0) ag1+=360
 if(ag2<0) ag2+=360
 if(ag3<0) ag3+=360
 var dir=1
 if(ag2<ag1&&(ag3>ag1||ag3<ag2)) dir=-1
 if(ag2>ag3&&ag3>ag1) dir=-1
 var ag0=ag3-ag1
 if(ag0<0) ag0+=360
 if(dir==-1) ag0=360-ag0
 for(var j=0;j<3;j++){
 ag2=ag0
 if(ag2<=120){
 ag4=ag1+dir*ag2/2
 var r4=r/Math.cos(ag2*Math.PI/360)
 var x4=x0+r4*Math.cos(ag4*Math.PI/180)
 var y4=y0+r4*Math.sin(ag4*Math.PI/180)
 ctx.arcTo(x4,y4,x3,y3,r)
 break
 }
 ag2=120
 ag0-=120
 ag4=ag1+dir*ag2/2
 ag1+=dir*ag2
 var r4=r/Math.cos(ag2*Math.PI/360)
 var x4=x0+r4*Math.cos(ag4*Math.PI/180)
 var y4=y0+r4*Math.sin(ag4*Math.PI/180)
 var x5=x0+r*Math.cos(ag1*Math.PI/180)
 var y5=y0+r*Math.sin(ag1*Math.PI/180)
 ctx.arcTo(x4,y4,x5,y5,r)
 }
 i+=2
 }
 else if(t==5){
 if(!is(Array,arr[i+2])) continue
 var x3=arr[i+2][0]
 var y3=arr[i+2][1]
 var x4=(4*x2-x1-x3)/2
 var y4=(4*y2-y1-y3)/2
 ctx.quadraticCurveTo(x4,y4,x3,y3)
 i+=2
 }
 }
 var a=arr[arr.length-1]
 if(a[0]==sp[0]&&a[1]==sp[1]){
 ctx.closePath()
 }
 if(arr[0]){
 var c=arr[0]
 if(!is(Array,c)){
 ctx.fillStyle=G.toColor(c)
 }
 else{
 var t=c[c.length-1]
 if(!is(Number,t)){
 c.push(1)
 t=1
 }
 if(t==2){
 var g=ctx.createLinearGradient(caller.w,0,0,caller.h)
 }
 else if(t==3){
 g=ctx.createLinearGradient(caller.w,0,0,0)
 }
 else if(t==4){
 g=ctx.createLinearGradient(caller.w,caller.h,0,0)
 }
 else{
 g=ctx.createLinearGradient(0,0,caller.w,0)
 }
 for(var i=0;i<c.length-1;i++){
 var s=c[i]
 var n=s.charAt(0)
 if(i==0) n=0
 if(i==c.length-2) n=10
 if(n=="#") continue
 g.addColorStop(n/10,G.toColor(s.replace(/^\d+/g,"")))
 }
 ctx.fillStyle=g
 }
 ctx.fill()
 }
 if(arr[1]){
 var s=arr[1]
 if(is(Array,s)){
 s=s[0]
 ctx.lineJoin="round"
 ctx.lineCap="round"
 }
 var n=s.indexOf("#")
 ctx.strokeStyle=G.toColor(s.slice(n))
 ctx.lineWidth=int(s.slice(0,n))||1
 ctx.stroke()
 }
 caller.div.style.backgroundImage="url("+G.canvas.toDataURL("image/png")+")"
 }
})();
(function(){
var Me=Class.extends("core.Button",Box);
Me.pressing=false
 
Me.proto.type=1
Me.proto.toggleMode=false
Me.proto.delayMode=true
 
Me.proto.label=null
Me.proto.img=null
Me.proto.arrowSign=null
Me.proto.toggled=false
Me.proto.src=null
Me.proto.text=null
Me.proto.toggleColor=null
Me.proto.toggleBgColor=null
Me.proto.baseColor=null
Me.proto.baseBgColor=null
Me.proto.arrow=false
Me.proto.__ctor=function(text,src){
 this.subEnabled=false
 if(this.__class==Button&&(text||src)){
 this.text=text
 this.src=src
 if(text&&!src){
 this.setTextButton()
 }
 else if(src){
 this.setImgButton()
 }
 }
 }
Me.proto.setTextButton=function(){
 this.type=3
 this.bg=["#fff","#ccc",5]
 this.label=this.addChild(Class.new(Label,this.text))
 this.label.__x="c"
 this.label.__y="c"
 this.label.w=this.label.getClientW()
 this.label.h=this.label.getClientH()
 this.setSize(160,60)
 }
Me.proto.setImgButton=function(){
 this.img=this.addChild(Class.new(Img,this.src))
 this.img.name="base"
 if(IO.resHash[this.src+"@"]){
 this.type=2
 this.img=this.addChild(Class.new(Img,this.src+"@"))
 this.img.name="base"
 }
 
 if(this.text){
 this.label=this.addChild(Class.new(Label,this.text))
 }
 this.setSize(this.img.w,this.img.h)
 }
Me.proto.resetSelf=function(){
 if(this.type==2&&this.children.length>1){
 this.children[0].setVisible(!this.toggled)
 this.children[1].setVisible(this.toggled)
 }
 else if(this.type==3){
 if(!is(Array,this.bg)) this.bg=[this.bg]
 if(!this.baseBgColor){
 this.baseBgColor=this.bg[0]||"#fff"
 }
 if(!this.toggleBgColor){
 var c=G.toColor(this.bg[0]||"#fff")
 var c2="#"
 for(var i=1;i<6;i+=2){
 var n=int(int("0x"+c.slice(i,i+2))*0.92)
 c2+=(n<16?"0":"")+n.toString(16)
 }
 this.toggleBgColor=c2
 }
 this.bg[0]=!this.toggled?this.baseBgColor:this.toggleBgColor
 this.setBg(this.bg)
 }
 if(this.toggleColor){
 if(!this.label) this.label=this.getChild("label")
 if(!this.baseColor) this.baseColor=this.label.color
 if(this.label){
 this.label.setColor(!this.toggled?this.baseColor:this.toggleColor)
 }
 }
 if(this.arrowSign){
 var h=this.getClientH()-(!this.padding?0:2*int(this.padding[0]))
 this.arrowSign.setPos("r-32",(h-this.arrowSign.h)/2)
 }
 
 }
Me.proto.click=function(){
 G.target=this
 this.dispatchEvent(G.newEvent(Evt.BUTTON_CLICK))
 }
Me.proto.setSize=function(w,h){
 Box.proto.setSize.call(this,w,h)
 var box=this.children[0]
 if(box&&box.name=="base") box.setSize(w,h)
 box=this.children[1]
 if(box&&box.name=="base") box.setSize(w,h)
 if(this.label) this.label.setPos(this.label.__x,this.label.__y)
 this.changeSelf()
 }
Me.proto.setSrc=function(v){
 this.src=v
 var resArr=IO.resHash[v]
 if(resArr){
 this.w=resArr[2]
 this.h=resArr[3]
 }
 if(this.img) this.img.setSrc(v)
 this.changeSelf()
 }
Me.proto.setText=function(v){
 this.text=v
 if(this.label){
 this.label.setText(v)
 this.label.w=this.label.getClientW()
 }
 this.changeSelf()
 }
Me.proto.resetBg=function(v){
 this.bg=v
 this.baseBgColor=null
 this.changeSelf()
 }
Me.proto.setToggled=function(v){
 this.toggled=v
 this.changeSelf()
 }
Me.proto.setArrow=function(v){
 this.arrow=v
 if(!v&&this.arrowSign){
 this.arrowSign.remove()
 this.arrowSign=null
 }
 if(v&&!this.arrowSign){
 var c=is(String,this.arrow)?this.arrow:"#bbb"
 this.arrowSign=this.addChild(Class.new(Box,{absolute:true,w:12,h:20,bg:[,"2"+c,"shape",[0,0],[12,10],[0,20]]}))
 this.changeSelf()
 }
 }
Me.proto.onPress=function(){
 if(Me.pressing) return
 Me.pressing=true
 if(this.toggleMode) return
 if(!this.delayMode||!this.inScroll()){
 this.setToggled(true)
 }
 else{
 callLater([this,this.onPress2],150)
 }
 }
Me.proto.onPress2=function(){
 if(G.isPressMove){
 Me.pressing=false
 return
 }
 this.setToggled(true)
 }
Me.proto.onRelease=function(){
 if(!Me.pressing) return
 Me.pressing=false
 if(this.toggleMode) return
 var clicked=false
 if(this.inScroll()){
 if(!G.isPressMove) clicked=true
 }
 else{
 if(this.hitTest(G.x,G.y)) clicked=true
 }
 if(!this.delayMode){
 this.setToggled(false)
 if(clicked) this.click()
 }
 else{
 callLater([this,this.onRelease2,clicked],200)
 }
 }
Me.proto.onRelease2=function(clicked){
 this.setToggled(false)
 if(this.delayMode&&clicked) this.click()
 }
Me.proto.onClick=function(){
 if(!this.toggleMode) return
 this.setToggled(!this.toggled)
 this.click()
 }
})();
(function(){
var Me=Class.extends("core.Dlg",Box);
Me.proto.closed=false
Me.proto.base=null
Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.setSize(G.w,G.h)
 this.addChild({dim:"base",w:"f",h:"f",bg:"#000",alpha:0.3})
 }
Me.proto.close=function(){
 if(this.closed) return
 this.closed=true
 this.onClose()
 }
Me.proto.onClose=function(){
 this.remove()
 }
Me.proto.onClick=function(){
 if(G.target==this.base) this.close()
 }
})();
(function(){
var Me=Class.extends("core.Drag",null);
Me.target=null
Me.range=null
Me.doDrag=null
Me.useSlide=null
Me.bounceSize=null
Me.isStartTrigger=false
Me.fromPos=null
Me.lastPos=null
Me.offsets=null
Me.speed=null
Me.isPressMoving=null
Me.start=function(target,range,doDrag,useSlide,bounceSize){
 Me.startTrigger()
 Me.target=target
 Me.range=range||[0,0,0,G.h-target.h]
 Me.doDrag=doDrag
 Me.useSlide=useSlide
 Me.bounceSize=bounceSize
 Me.fromPos={x:target.x,y:target.y}
 Me.lastPos={x:target.x,y:target.y}
 Me.offsets=[]
 Me.isPressMoving=true
 }
Me.stop=function(){
 if(!Me.target) return
 Me.target.setPos(Me.fromPos.x,Me.fromPos.y)
 Me.target=null
 }
Me.pressMove=function(){
 if(!G.isPress){
 Me.isPressMoving=false
 Me.startSlide()
 return
 }
 Me.target.setPos(Me.fromPos.x+(G.x-G.pressX),Me.fromPos.y+(G.y-G.pressY))
 Me.checkRange()
 Me.offsets.push({x:Me.target.x-Me.lastPos.x,y:Me.target.y-Me.lastPos.y})
 if(Me.offsets.length>6) Me.offsets.shift()
 Me.lastPos.x=Me.target.x
 Me.lastPos.y=Me.target.y
 }
Me.startSlide=function(){
 if(!Me.useSlide||Me.offsets.length==0){
 Me.finish()
 return
 }
 Me.speed={x:0,y:0}
 for(var i=0;i<Me.offsets.length;i++){
 var p=Me.offsets[i]
 Me.speed.x+=p.x
 Me.speed.y+=p.y
 }
 Me.speed.x=2*Me.speed.x/Me.offsets.length
 Me.speed.y=2*Me.speed.y/Me.offsets.length
 }
Me.slideMove=function(){
 Me.speed.x*=0.92
 Me.speed.y*=0.92
 if(Math.abs(Me.speed.x)<1) Me.speed.x=0
 if(Math.abs(Me.speed.y)<1) Me.speed.y=0
 Me.target.setPos(Me.target.x+Me.speed.x,Me.target.y+Me.speed.y)
 Me.checkRange()
 if(Me.lastPos.x==Me.target.x&&Me.lastPos.y==Me.target.y){
 Me.finish()
 return
 }
 Me.lastPos.x=Me.target.x
 Me.lastPos.y=Me.target.y
 }
Me.checkRange=function(){
 var x=Math.min(Math.max(Me.target.x,Me.range[0]),Me.range[0]+Me.range[2])
 var y=Math.min(Math.max(Me.target.y,Me.range[1]),Me.range[1]+Me.range[3])
 Me.target.setPos(x,y)
 call(Me.doDrag,false)
 }
Me.finish=function(){
 call(Me.doDrag,true)
 Me.target=null
 }
Me.startTrigger=function(){
 if(Me.isStartTrigger) return
 Me.isStartTrigger=true
 G.addFrameCall([Me.onFrame])
 }
Me.onFrame=function(){
 var now=G.now
 if(Me.target){
 if(Me.isPressMoving){
 Me.pressMove()
 }
 else{
 Me.slideMove()
 }
 }
 }
})();
(function(){
var Me=Class.extends("core.Evt",null);
Me.PRESS="press"
Me.RELEASE="release"
Me.CLICK="click"
Me.KEY_DOWN="keyDown"
Me.BUTTON_CLICK="buttonClick"
Me.CHANGE="change"
 
})();
(function(){
var Me=Class.extends("core.EvtAid",null);
Me.lastTouchNum=0
Me.lastDocW=0
Me.touchStartY=null
Me.exitHintLabel=null
Me.gestureStep=0
 
Me.isIosFirstBack=true
Me.init=function(){
 Me.lastDocW=document.documentElement.clientWidth
 if(G.os==1){
 window.onmousedown=Me.onMouseEvent
 window.onmouseup=Me.onMouseEvent
 window.onmousemove=Me.onMouseEvent
 window.onkeydown=Me.onKeyDown
 }
 else{
 window.ontouchstart=Me.onTouchEvent
 window.ontouchmove=Me.onTouchEvent
 window.ontouchend=Me.onTouchEvent
 }
 Me.isIosFirstBack=true
 window.onresize=Me.onResize
 Me.playTime()
 }
Me.onMouseEvent=function(evt){
 if(evt.button==2){
 if(Shell){
 GAid.createQRLink()
 }
 GAid.resetChanged()
 return
 }
 var ex=int(evt.clientX/G.scale)
 var ey=int(evt.clientY/G.scale)
 if(evt.type=="mousedown"){
 G.touchs=[[ex,ey]]
 }
 else if(evt.type=="mousemove"){
 if(G.touchs.length==0) return
 G.touchs=[[ex,ey]]
 }
 else if(evt.type=="mouseup"){
 G.touchs=[]
 }
 Me.onEvent(evt)
 if(evt.type=="mouseup"&&GAid.qrBox){
 GAid.qrBox.remove()
 GAid.qrBox=null
 }
 }
Me.onTouchEvent=function(evt){
 G.touchs=[]
 var touches=evt.touches
 var ex=0
 var ey=0
 for(var i=0;i<touches.length;i++){
 var t=touches[i]
 ex=int(t.clientX/G.scale)
 ey=int(t.clientY/G.scale)
 G.touchs.push([ex,ey])
 }
 Me.onEvent(evt)
 if(evt.type=="touchstart"){
 Me.touchStartY=ey
 G.renderIos=true
 }
 if(evt.type=="touchend"){
 Me.touchStartY=ey
 }
 if(evt.type=="touchmove"){
 var div=evt.target
 var prevent=true
 while(div&&div!=document.body){
 if(div.scroll&&ey>Me.touchStartY&&div.scrollTop>0){
 prevent=false
 }
 if(div.scroll&&ey<Me.touchStartY&&div.scrollTop+3<div.scrollHeight-div.clientHeight){
 prevent=false
 }
 div=div.parentNode
 }
 if(GAid.traceDiv) prevent=false
 if(prevent) evt.preventDefault()
 }
 }
Me.onEvent=function(evt){
 var target=evt.target.box||G.stage
 var num=G.touchs.length
 var x=num==0?0:int(G.touchs[G.touchs.length-1][0])
 var y=num==0?0:int(G.touchs[G.touchs.length-1][1])
 if(num>Me.lastTouchNum){
 G.pressX=x
 G.pressY=y
 G.x=x
 G.y=y
 G.isPress=true
 G.target=target
 G.pressTime=G.now
 G.holdTime=G.now
 G.isPressMove=false
 if(GAid.traceDiv&&evt.target!=GAid.traceDiv){
 document.body.removeChild(GAid.traceDiv)
 GAid.traceDiv=null
 }
 G.target.dispatchEvent(G.newEvent(Evt.PRESS))
 GAid.resetChanged()
 G.isPress=true
 }
 else if(num<Me.lastTouchNum){
 if(G.isPress){
 if(!G.isPressMove&&G.target){
 G.target.dispatchEvent(G.newEvent(Evt.CLICK))
 }
 G.target.dispatchEvent(G.newEvent(Evt.RELEASE))
 GAid.resetChanged()
 }
 G.isPress=false
 G.target=null
 }
 if(num>0){
 if(G.x!=x||G.y!=y){
 G.x=x
 G.y=y
 G.holdTime=G.now
 }
 if(Math.distance(G.pressX,G.pressY,G.x,G.y)>10){
 G.isPressMove=true
 }
 }
 else{
 G.holdTime=0
 }
 Me.lastTouchNum=num
 }
Me.onKeyDown=function(evt){
 var data={keyCode:evt.keyCode,ctrlKey:evt.ctrlKey,shiftKey:evt.shiftKey,altKey:evt.altKey,metaKey:evt.metaKey}
 G.stage.dispatchEvent(G.newEvent(Evt.KEY_DOWN,data))
 if(evt.keyCode==116){
 location.reload(true)
 }
 else if(evt.keyCode==27){
 if(G.platform==1) Me.onPopState()
 }
 else if(G.platform==1&&evt.keyCode==8&&evt.ctrlKey){
 history.back()
 }
 }
Me.onResize=function(evt){
 var docW=document.documentElement.clientWidth
 var docH=document.documentElement.clientHeight
 if(G.os==1){
 G.scale=docW/docH<1.57?docW/GAid.designW:docH/(GAid.designW*1.57)
 document.documentElement.style[G.toCssKey("Transform")]="scale("+G.scale+","+G.scale+")"
 }
 G.w=int(docW/G.scale)
 G.h=int(docH/G.scale)
 if(G.os>1&&G.w>G.h) G.h=GAid.designW*1.57
 G.stage.setSize(G.w,G.h)
 G.main.setSize(G.w,G.h)
 }
Me.playTime=function(){
 if(G.isPress){
 if(Me.gestureStep==0){
 if(G.x>G.w-100) Me.gestureStep=1
 }
 if(Me.gestureStep==1){
 if(G.x<100) Me.gestureStep=2
 }
 if(Me.gestureStep==2){
 if(G.now-G.holdTime>300){
 Me.gestureStep=0
 if(G.y<G.h/2){
 location.reload(true)
 }
 else if(window.Log){
 Log.show()
 }
 }
 if(G.x>100) Me.gestureStep=0
 }
 }
 else{
 Me.gestureStep=0
 }
 callLater([Me.playTime])
 }
})();
(function(){
var Me=Class.extends("core.G",null);
Me.max=2147483647
 
Me.platform=1
 
Me.os=1
Me.path=null
Me.url=null
Me.config=null
Me.stage=null
Me.main=null
Me.page=null
Me.param={}
Me.style={}
Me.bgStyle={}
Me.canvas=null
Me.target=null
Me.x=0
Me.y=0
Me.pressX=0
Me.pressY=0
Me.pressTime=0
Me.holdTime=0
Me.isPress=false
Me.isPressMove=false
Me.touchs=[]
Me.now=null
Me.time=null
Me.interval=null
Me.title=null
Me.renderIos=false
 
Me.start=function(){
 GAid.start()
 }
Me.close=function(){
 GAid.close()
 }
Me.setTitle=function(text){
 GAid.setTitle(text)
 }
Me.adjustTime=function(time){
 GAid.adjustTime(time)
 }
Me.toColor=function(v){
 return GAid.toColor(v)
 }
Me.toCssKey=function(k){
 return GAid.toCssKey(k)
 }
Me.newEvent=function(type,data){
 return GAid.newEvent(type,data)
 }
})();
(function(){
var Me=Class.extends("core.GAid",null);
Me.params=[]
Me.designW=null
Me.startTime=0
Me.timeDiff=0
Me.lastDesignTime=null
Me.designCode=null
Me.laterCalls=[]
Me.nextLaters=[]
Me.changedHash=null
Me.scrollChangedHash=null
Me.removeCalled=false
Me.qrBox=null
Me.traceDiv=null
Me.traceText=""
Me.trackIframe=null
Me.singleId=null
Me.singleTime=0
Me.start=function(){
 window.trace=Me.trace
 Me.initPlatform()
 IO.setRes("res/",[Me.start2])
 }
Me.start2=function(){
 Me.initTime()
 EvtAid.init()
 Me.initStage()
 if(window.Log) Log.init()
 Class.new(Main)
 Me.resetChanged()
 }
Me.close=function(){
 if(G.platform==1){
 window.close()
 return
 }
 if(!window.WeixinJSBridge){
 callLater([Me.close],100)
 return
 }
 WeixinJSBridge.invoke("closeWindow")
 }
Me.initPlatform=function(){
 var agent=navigator.userAgent
 var platform=navigator.platform
 if(agent.indexOf("MicroMessenger")>-1){
 G.platform=2
 }
 else if(!Shell){
 G.platform=3
 }
 if(platform.indexOf("Win")==0||platform.indexOf("MacIntel")==0){
 G.os=1
 }
 else if(agent.indexOf("Android")>-1){
 G.os=2
 }
 else{
 G.os=3
 }
 G.path=document.URL.replace(/[^\/]+$/g,"")
 G.url=G.path+"index.html"
 G.config=System.config
 }
Me.initStage=function(){
 var meta=document.getElementsByTagName("meta")["viewport"]
 var m=meta.content.match(/width=(\d+)/)
 Me.designW=int(m[1])
 document.documentElement.style.cssText="width:100%;height:100%"
 var docW=document.documentElement.clientWidth
 var docH=document.documentElement.clientHeight
 G.scale=docW/docH<1.57?docW/Me.designW:docH/(Me.designW*1.57)
 if(G.os>1) G.scale=1
 G.w=int(docW/G.scale)
 G.h=int(docH/G.scale)
 if(G.scale!=1){
 document.documentElement.style[G.toCssKey("TransformOrigin")]="0 0"
 document.documentElement.style[G.toCssKey("Transform")]="scale("+G.scale+","+G.scale+")"
 }
 if(G.os>1&&G.w>G.h) G.h=Me.designW*1.57
 Me.renderDiv=document.createElement("div")
 document.body.appendChild(Me.renderDiv)
 Me.renderDiv.style.visibility="hidden"
 
 GAid.trackIframe=document.createElement("iframe")
 document.body.appendChild(GAid.trackIframe)
 GAid.trackIframe.style.display="none"
 GAid.trackIframe.src="js/act.html"
 G.stage=Class.new(Stage)
 for(var i=0;i<Me.params.length;i++){
 var a=Me.params[i]
 if(a[1]==null) a[1]=1
 if(a[1]=="0"||a[1]=="1") a[1]=int(a[1])
 G.param[a[0]]=a[1]
 }
 }
Me.setTitle=function(text){
 G.title=text
 if(G.platform==1){
 Shell.ipcRenderer.send("setTitle",text)
 }
 else{
 document.title=text
 }
 if(G.os==3&&GAid.trackIframe&&GAid.trackIframe.contentWindow.location.href!="about:blank"){
 GAid.trackIframe.contentWindow.location.reload(true)
 }
 }
Me.initTime=function(){
 Me.startTime=new Date().valueOf()
 G.now=Me.startTime
 Me.playTime()
 setInterval(Me.playTime,16)
 }
Me.adjustTime=function(time){
 G.time=time
 Me.timeDiff=G.time-int(new Date().valueOf()/1000)
 }
Me.createQRLink=function(){
 if(Me.qrBox) return
 var os=require("os")
 var ifaces=os.networkInterfaces()
 var ip="127.0.0.1"
 for(var k in ifaces){
 var a=ifaces[k]
 for(var i=0;i<a.length;i++){
 var obj=a[i]
 if(obj.family=="IPv4"&&!obj.internal){
 ip=obj.address
 }
 }
 }
 Me.qrBox=G.stage.addChild([
 [{w:"f",h:"f",bg:"#6000"},
 [{w:240,h:240,x:"c",y:"c",bg:"#fff"}]
 ]
 ])
 var box=Me.qrBox.children[0]
 box.div.style.padding="20px"
 var qr=new QRCode(box.div,{width:200,height:200})
 qr.makeCode("http://"+ip+":8000")
 }
Me.trace=function(){
 if(!Me.traceDiv){
 Me.traceText=""
 Me.traceDiv=document.createElement("div")
 document.body.appendChild(Me.traceDiv)
 Me.traceDiv.selectable=true
 Me.traceDiv.style.cssText="position:absolute;width:"+G.w+"px;padding:5px;font-size:24px;-webkit-touch-callout:initial;-webkit-user-select:initial;font-family:Microsoft Yahei,PingFangSC-Light;background:"+G.toColor("#8000")
 }
 var str=""
 for(var i=0;i<arguments.length;i++){
 var v=arguments[i]
 if(str!="") str+=" "
 if(v==null) v="null"
 str+=v
 }
 if(str=="") str="　"
 if(Me.traceText!="") Me.traceText+="\n"
 Me.traceText+=str
 
 Me.traceDiv.style.overflow="auto"
 Me.traceDiv.style.height="auto"
 Me.traceDiv.innerText=Me.traceText
 Me.traceDiv.style.color="#ffffff"
 if(Me.traceDiv.offsetHeight>220){
 Me.traceDiv.style.height="220px"
 Me.traceDiv.style.overflow="scroll"
 Me.traceDiv.scrollTop=Me.traceDiv.scrollHeight
 }
 Me.traceDiv.style.top=(G.h-Me.traceDiv.offsetHeight)+"px"
 }
Me.toColor=function(c){
 if(!c||c=="#none") return "transparent"
 if(c.length<=5){
 var str="#"
 for(var i=1;i<c.length;i++){
 var s=c.charAt(i)
 str+=s+(s=="f"?"f":"0")
 }
 c=str
 }
 if(c.length==9){
 var s=""
 for(var i=0;i<4;i++){
 var n=(i==3?0:i+1)*2+1
 s+=int("0x"+c.slice(n,n+2))/(i==3?255:1)+","
 }
 return "rgba("+s.slice(0,-1)+")"
 }
 return c
 }
Me.toCssKey=function(k){
 var isFF=navigator.userAgent.indexOf("Firefox")>-1
 var isIE=window.ActiveXObject!=null
 var c=k.charCodeAt(0)
 if(isIE){
 if(k=="UserSelect") return "ms"+k
 if(k=="user-select") return "-ms-"+k
 }
 if(c>=65&&c<=90){
 if(isFF||isIE) return k.slice(0,1).toLowerCase()+k.slice(1)
 return "webkit"+k
 }
 else{
 if(isFF||isIE) return k
 return "-webkit-"+k
 }
 }
Me.newEvent=function(type,data){
 var evt=document.createEvent("HTMLEvents")
 evt.initEvent(type,true,true)
 evt.enabled=true
 for(var k in data){
 evt[k]=data[k]
 }
 return evt
 }
Me.addFrameCall=function(foo){
 for(var i=0;i<Me.frameCalls.length;i++){
 var foo2=Me.frameCalls[i]
 if(is(Function,foo2[0])){
 if(foo[0]==foo2[0]) return
 }
 else{
 if(foo[0]==foo2[0]&&foo[1]==foo2[1]) return
 }
 }
 Me.frameCalls.push(foo)
 }
Me.removeFrameCall=function(caller,func){
 for(var i=Me.frameCalls.length-1;i>=0;i--){
 var foo2=Me.frameCalls[i]
 if(is(Function,foo2[0])){
 if(caller==foo2[0]) Me.frameCalls.splice(i,1)
 }
 else{
 if(caller==foo2[0]&&func==foo2[1]) Me.frameCalls.splice(i,1)
 }
 }
 }
Me.testDesign=function(){
 if(!window.Shell||!G.param.design) return
 if(!Me.designCode){
 Me.lastDesignTime=G.now
 Me.designCode=IO.readFile("code/"+G.param.design)
 return
 }
 if(G.now-Me.lastDesignTime<300) return
 Me.lastDesignTime=G.now
 var code=IO.readFile("code/"+G.param.design)
 if(code!=Me.designCode){
 Me.designCode=code
 location.reload(true)
 }
 }
Me.resetChanged=function(){
 if(G.os==3&&G.renderIos){
 G.renderIos=false
 document.body.removeChild(Me.renderDiv)
 document.body.appendChild(Me.renderDiv)
 }
 for(var i=0;i<Me.laterCalls.length;i++){
 var obj=Me.laterCalls[i]
 if(obj.status==1&&obj.time<=0){
 obj.status=2
 call(obj.foo)
 }
 }
 for(var i=Me.laterCalls.length-1;i>=0;i--){
 var obj=Me.laterCalls[i]
 if(obj.status==3){
 Me.laterCalls.splice(i,1)
 }
 }
 if(Me.changedHash){
 var hash={}
 for(var k in Me.changedHash){
 hash[k]=Me.changedHash[k]
 }
 Me.changedHash=null
 for(var k in hash){
 var box=hash[k]
 if(!box.removed) box.resetSelf()
 }
 if(Me.changedHash) Me.resetChanged()
 }
 if(Me.scrollChangedHash){
 for(var k in Me.scrollChangedHash){
 var box=Me.scrollChangedHash[k]
 box.setScroll(box.div.scrollHeight>box.div.clientHeight)
 box.scroll=true
 }
 Me.scrollChangedHash=null
 }
 }
Me.testSingle=function() {
 if(!window.Shell) return
 if(!Me.singleId){
 var stat=Shell.fs.statSync(Shell.path+"js/dream-code.js")
 Me.singleId=stat.mtime+""
 }
 if(G.now-G.singleTime<200) return
 G.singleTime=G.now
 var stat=Shell.fs.statSync(Shell.path+"js/dream-code.js")
 var singleId=stat.mtime+""
 if(Me.singleId!=singleId){
 Me.singleId=singleId
 G.close()
 }
 }
Me.playTime=function(){
 var t=new Date().valueOf()
 var now=t-Me.startTime
 G.interval=now-G.now
 G.now=now
 G.time=int(t/1000)+Me.timeDiff
 
 for(var i=0;i<Me.laterCalls.length;i++){
 var obj=Me.laterCalls[i]
 obj.time-=G.interval
 if(obj.status==2) obj.status=3
 }
 Me.resetChanged()
 Me.testDesign()
 Me.testSingle()
 }
})();
(function(){
var Me=Class.extends("core.Img",Box);
Me.proto.src=null
Me.proto.loadSrc=null
Me.proto.loadSize=null
Me.proto.frame=1
Me.proto.__ctor=function(src){
 if(this.__class==Img&&src){
 var resArr=IO.resHash[src]
 if(resArr){
 this.enabled=false
 this.src=src
 var extra=resArr[1]
 this.w=resArr[2]
 this.h=resArr[3]
 var n=extra.indexOf("/")
 var ext=n==-1?"png":extra.slice(n+1)
 var filePath=IO.resPath+src.replace(/\./g,"/")+"."+ext+"?"+resArr[1]
 this.div.style.cssText="pointer-events:none;width:"+this.w+"px;height:"+this.h+"px;background-image:url("+filePath+")"
 return
 }
 this.setSrc(src)
 }
 this.setEnabled(false)
 }
Me.proto.resetSelf=function(){
 var src=this.src
 if(!src) return
 if(src.indexOf("/")>-1){
 this.div.style.width=this.w+"px"
 this.div.style.height=this.h+"px"
 this.div.style.backgroundImage="url("+src+")"
 this.div.style.backgroundSize=this.w+"px "+this.h+"px"
 return
 }
 var resArr=IO.resHash[src]
 if(!resArr||this.w==0||this.h==0){
 this.div.style.width="0px"
 this.div.style.height="0px"
 this.div.style.backgroundImage="none"
 return
 }
 var extra=resArr[1]
 var w0=resArr[2]
 var h0=resArr[3]
 var w=this.w
 var h=this.h
 this.div.style.width=w+"px"
 this.div.style.height=h+"px"
 this.w=w
 this.h=h
 var style=G.style[src]
 var g=style?style.grid9:null
 if(!g&&src.slice(-1)=="@"){
 style=G.style[src.slice(0,-1)]
 g=style?style.grid9:null
 }
 if(extra.charAt(0)=="("){
 var baseSrc=extra.slice(1,-1)
 var resArr2=IO.resHash[baseSrc]
 var baseW=resArr2[2]
 var baseH=resArr2[3]
 var shiftX=resArr[6]
 var shiftY=resArr[7]
 }
 else{
 baseSrc=src
 baseW=w0
 baseH=h0
 shiftX=0
 shiftY=0
 }
 var n=extra.indexOf("/")
 var ext=n==-1?"png":extra.slice(n+1)
 var filePath=IO.resPath+baseSrc.replace(/\./g,"/")+"."+ext+"?"+resArr[1]
 if(!g){
 this.div.style.backgroundImage="url("+filePath+")"
 this.div.style.backgroundPosition=(-shiftX*w/w0)+"px "+(-shiftY*h/h0)+"px"
 this.div.style.backgroundSize=(baseW*w/w0)+"px "+(baseH*h/h0)+"px"
 return
 }
 if(g[2]==null) g[2]=0
 if(g[3]==null) g[3]=0
 var w=Math.max(w,g[0]+g[1])
 var h=Math.max(h,g[2]+g[3])
 var arr=[
 [0,0,g[0],g[2],							0,0,g[0],g[2]],
 [w0-g[1],0,g[1],g[2],					w-g[1],0,g[1],g[2]],
 [0,h0-g[3],g[0],g[3],					0,h-g[3],g[0],g[3]],
 [w0-g[1],h0-g[3],g[1],g[3],				w-g[1],h-g[3],g[1],g[3]],
 [g[0],0,w0-g[0]-g[1],g[2],				g[0],0,w-g[0]-g[1],g[2]],
 [0,g[2],g[0],h0-g[2]-g[3],				0,g[2],g[0],h-g[2]-g[3]],
 [w0-g[1],g[2],g[1],h0-g[2]-g[3],		w-g[1],g[2],g[1],h-g[2]-g[3]],
 [g[0],h0-g[3],w0-g[0]-g[1],g[3],		g[0],h-g[3],w-g[0]-g[1],g[3]],
 [g[0],g[2],w0-g[0]-g[1],h0-g[2]-g[3],	g[0],g[2],w-g[0]-g[1],h-g[2]-g[3]]
 ]
 var index=0
 for(var i=0;i<arr.length;i++){
 var a=arr[i]
 if(a[2]==0||a[3]==0) continue
 if(a[6]<=0||a[7]<=0) continue
 var span=this.children[index++]
 if(!span){
 span=document.createElement("span")
 this.div.appendChild(span)
 span.style.position="absolute"
 span.style.backgroundRepeat="no-repeat"
 }
 span.style.left=a[4]+"px"
 span.style.top=a[5]+"px"
 span.style.width=a[6]+"px"
 span.style.height=a[7]+"px"
 span.style.backgroundImage="url("+filePath+")"
 span.style.backgroundPosition=(-int(shiftX+a[0])*a[6]/a[2])+"px "+(-int(shiftY+a[1])*a[7]/a[3])+"px"
 span.style.backgroundSize=Math.ceil(baseW*a[6]/a[2])+"px "+Math.ceil(baseH*a[7]/a[3])+"px"
 }
 }
Me.proto.setSize=function(w,h){
 Box.proto.setSize.call(this,w,h)
 this.changeSelf()
 }
Me.proto.setSrc=function(v){
 if(!v) return
 this.src=v
 var resArr=IO.resHash[v]
 if(!resArr&&IO.resFrameHash[this.src]){
 this.src+="."+IO.resFrameHash[this.src]
 resArr=IO.resHash[this.src]
 }
 var n=this.src.lastIndexOf(".")
 this._frame=this.src.slice(-1)=="@"?0:Math.max(int(this.src.slice(n+1)),1)
 if(v.indexOf("/")>-1){
 this.w=100
 this.h=100
 }
 else if(resArr){
 this.w=resArr[2]
 this.h=resArr[3]
 if(resArr.length>=6){
 this.pivot=[resArr[4],resArr[5]]
 }
 }
 this.setSize(this.w,this.h)
 }
Me.proto.setLoadSrc=function(v){
 this.loadSrc=v
 var image=new Image()
 image.src=this.loadSrc
 image.self=this
 image.onload=this.onSrcLoad
 }
Me.proto.setFrame=function(f){
 var src=this.src
 if(src.slice(-1)=="@"){
 if(f==1) this.setSrc(src.slice(0,-1))
 return
 }
 else if(IO.resHash[src+"@"]){
 if(f==0) this.setSrc(src+"@")
 return
 }
 var n=src.lastIndexOf(".")
 src=src.slice(0,n)+"."+f
 if(src!=this.src){
 this.setSrc(src)
 }
 }
Me.proto.setGrid9=function(v){
 if(!this.src) return
 this.grid9=v
 if(!G.style[this.src]) G.style[this.src]={}
 var style=G.style[this.src]
 style.grid9=v
 }
Me.proto.onSrcLoad=function(evt){
 var image=evt.target
 var self=image.self
 var w=!self.loadSize?0:int(self.loadSize[0])
 var h=!self.loadSize?0:int(self.loadSize[1])
 var isAuto=!self.loadSize?false:self.loadSize[2]
 if(w==0&&h==0){
 w=image.width
 h=image.height
 }
 else if(w==0){
 w=h*image.width/image.height
 }
 else if(h==0){
 h=w*image.height/image.width
 }
 else if(isAuto){
 w=w/h>image.width/image.height?Math.ceil(h*image.width/image.height):w
 h=w/h>image.width/image.height?h:Math.ceil(w*image.height/image.width)
 }
 self.setSrc(image.src)
 self.setSize(w,h)
 if(is(String,self.__x)||is(String,self.__y)){
 self.setPos(self.__x,self.__y)
 }
 }
})();
(function(){
var Me=Class.extends("core.Input",Box);
Me.proto.doEnter=null
Me.proto.doChange=null
Me.proto.field=null
Me.proto.form=null
Me.proto.color="#000"
Me.proto.fontSize=24
Me.proto.maxLength=null
Me.proto.align="left"
Me.proto.type="text"
Me.proto.placeholder=null
Me.proto.multi=false
Me.proto.readOnly=false
Me.proto.text=""
Me.proto.__ctor=function(){
 while(this.div.children.length>0){
 this.div.removeChild(this.div.children[0])
 }
 this.field=document.createElement("input")
 this.div.appendChild(this.field)
 this.field.style.cssText="width:100%;height:100%;font-size:24px;padding:5px;"+G.toCssKey("box-sizing")+":border-box;background:transparent;border:none;outline:medium"
 this.field.selectable=true
 this.field.oninput=this.onFieldInput
 this.div.style[G.toCssKey("TouchCallout")]="initial"
 this.div.style[G.toCssKey("UserSelect")]="initial"
 this.setSize(400,36)
 }
Me.proto.resetSelf=function(){
 if(this.doEnter&&!this.form&&this.type=="text"){
 this.form=document.createElement("form")
 this.div.appendChild(this.form)
 this.form.style.cssText="width:100%;height:100%"
 this.form.appendChild(this.field)
 this.form.onsubmit=this.onFormSubmit
 }
 }
Me.proto.focus=function(){
 callLater([this.field,this.field.focus],100)
 }
Me.proto.blur=function(){
 callLater([this.field,this.field.blur],100)
 }
Me.proto.scrollEnd=function(){
 this.field.scrollTop=this.field.scrollHeight
 }
Me.proto.setSize=function(w,h){
 Box.proto.setSize.call(this,w,h)
 this.changeSelf()
 }
Me.proto.setColor=function(v){
 this.color=v
 this.field.style.color=G.toColor(v)
 }
Me.proto.setFontSize=function(v){
 this.fontSize=v
 this.field.style.fontSize=v+"px"
 }
Me.proto.setMaxLength=function(v){
 this.maxLength=v
 this.field.maxLength=v
 }
Me.proto.setAlign=function(v){
 this.align=v
 this.field.style.textAlign=v
 }
Me.proto.setType=function(v){
 this.type=v
 this.field.type=v
 }
Me.proto.setPlaceholder=function(v){
 this.placeholder=v
 this.field.placeholder=v
 }
Me.proto.getText=function(){
 return this.field.value
 }
Me.proto.setText=function(v){
 this.text=v
 this.field.value=v
 call(this.doChange)
 }
Me.proto.setReadOnly=function(v){
 this.readOnly=v
 this.field.readOnly=v
 }
Me.proto.setMulti=function(v){
 if(this.multi==v) return
 this.multi=v
 var field0=this.field
 this.div.removeChild(field0)
 this.field=document.createElement(v?"textarea":"input")
 this.div.appendChild(this.field)
 if(v){
 this.field[G.toCssKey("OverflowScrolling")]="touch"
 this.field.scroll=true
 }
 this.field.oninput=this.onFieldInput
 this.field.selectable=true
 this.field.style.cssText=field0.style.cssText
 this.field.value=field0.value
 this.field.readOnly=field0.readOnly
 this.field.wrap="soft"
 }
Me.proto.onFormSubmit=function(evt){
 var caller=evt.target.parentNode.box
 call(caller.doEnter)
 return false
 }
Me.proto.onFieldInput=function(evt){
 var target=evt.target.parentNode
 if(target.tagName=="FORM"){
 target=target.parentNode
 }
 var caller=target.box
 caller.text=evt.target.value
 call(caller.doChange)
 }
})();
(function(){
var Me=Class.extends("core.IO",null);
Me.resPath=null
Me.resHash={}
Me.resFrameHash={}
Me.setRes=function(path,doBack){
 IOAid.setRes(path,doBack)
 }
Me.readFile=function(path){
 return System.readFile(path)
 }
Me.viewImage=function(urls,index){
 IOAid2.viewImage(urls,index)
 }
Me.uploadImage=function(doBack){
 IOAid.uploadImage(doBack)
 }
Me.getUrlParam=function(key){
 return IOAid.getUrlParam(key)
 }
Me.getCookie=function(name){
 return IOAid.getCookie(name)
 }
Me.setCookie=function(name,value){
 return IOAid.setCookie(name,value)
 }
Me.getStorage=function(name){
 return window.localStorage[name]
 }
Me.setStorage=function(name,value){
 IOAid.setStorage(name,value)
 }
Me.getGeolocation=function(doBack){
 IOAid.getGeolocation(doBack)
 }
Me.shakeBack=function(doShake){
 IOAid.shakeBack(doShake)
 }
})();
(function(){
var Me=Class.extends("core.IOAid",null);
Me.shakeData=null
Me.doShake=null
Me.doSetRes=null
Me.setRes=function(path,doBack){
 Me.doSetRes=doBack
 IO.resPath=path
 var script=document.createElement("script")
 document.body.appendChild(script)
 script.onload=Me.setRes2
 script.src=path+"@.js?"+G.config.version
 }
Me.setRes2=function(evt){
 document.body.removeChild(evt.target)
 var arr=t
 IO.resHash={}
 IO.resFrameHash={}
 for(var i=0;i<arr.length;i++){
 var str=arr[i]
 var a=str.split(",")
 var k=a[0]
 for(var j=2;j<a.length;j++){
 a[j]=int(a[j])
 }
 IO.resHash[k]=a
 var n=k.lastIndexOf(".")
 var f=int(k.slice(n+1))
 if(f>0){
 var k2=k.slice(0,n)
 if(IO.resFrameHash[k2]==null) IO.resFrameHash[k2]=G.max
 IO.resFrameHash[k2]=Math.min(IO.resFrameHash[k2],f)
 }
 }
 call(Me.doSetRes)
 }
Me.viewImage=function(urls,index){
 if(G.platform==2){
 if(!window.WeixinJSBridge){
 G.stage.setEnabled(false)
 callLater([Me.viewImage,urls,index],500)
 return
 }
 G.stage.setEnabled(true)
 for(var i=0;i<urls.length;i++){
 var url=urls[i]
 if(url.indexOf("http:")!=0&&url.indexOf("file:")!=0){
 url=G.path+url
 }
 urls[i]=url
 }
 WeixinJSBridge.invoke("imagePreview",{
 current:urls[index],
 urls:urls
 })
 return
 }
 var slideBar=G.stage.addChild(SlideBar)
 slideBar.setSize("f","f")
 slideBar.setBg("#000")
 slideBar.dotBox.setVisible(false)
 for(var i=0;i<urls.length;i++){
 var url=urls[i]
 slideBar.addChild([
 [{w:"f",h:"f"},
 [Img,{pos:["c","c"],loadSrc:url,loadSize:[G.w,G.h,true]}]
 ]
 ])
 }
 slideBar.index=index
 }
Me.getUrlParam=function(key){
 var s=unescape(document.URL)
 var n=s.indexOf("#"+key+"=")
 if(n==-1) n=s.indexOf("&"+key+"=")
 if(n==-1) return null
 s=s.slice(n+key.length+2)
 n=s.indexOf("#")
 if(n==-1) n=s.indexOf("&")
 if(n>-1) s=s.slice(0,n)
 return s
 }
Me.getGeolocation=function(doBack){
 Me.doGeoBack=doBack
 var geo=navigator["geolocation"]
 geo["getCurrentPosition"](Me.getGeolocation2,Me.getGeolocation3)
 }
Me.getGeolocation2=function(position){
 call(Me.doGeoBack,position)
 }
Me.getGeolocation3=function(error){
 call(Me.doGeoBack)
 }
Me.shakeBack=function(doShake){
 Me.doShake=doShake
 window.ondevicemotion=!doShake?null:Me.shakeBack2
 }
Me.shakeBack2=function(evt){
 if(!Me.doShake){
 window.ondevicemotion=null
 return
 }
 var acc=evt.accelerationIncludingGravity
 if(!Me.shakeData){
 Me.shakeData={x:acc.x,y:acc.y,z:acc.z,time:G.now}
 }
 var data=Me.shakeData
 var timeDiff=G.now-data.time
 if(timeDiff<10) return
 data.time=G.now
 var speed=(Math.abs(acc.x-data.x)+Math.abs(acc.y-data.y)+Math.abs(acc.z-data.z))/timeDiff*10000
 data.x=acc.x
 data.y=acc.y
 data.z=acc.z
 if(speed<10000) return
 Me.shakeData.time=G.now+1000
 var caller=Me.doShake
 if(caller.__isBox&&!caller.stage){
 Me.doShake=null
 return
 }
 call(Me.doShake)
 }
Me.getCookie=function(name){
 var reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)")
 var arr=document.cookie.match(reg)
 if(arr) return unescape(arr[2])
 return null
 }
Me.setCookie=function(name,value){
 var d=new Date()
 d.setTime(d.getTime()+30*24*60*60*1000)
 document.cookie=name+"="+escape(value)+";expires="+d.toGMTString()
 }
Me.setStorage=function(name,value){
 if(value==null){
 window.localStorage.removeItem(name)
 return
 }
 if(is(Number,value)){
 value+=""
 }
 else if(!is(String,value)){
 value=enjson(value)
 }
 window.localStorage[name]=value
 }
})();
(function(){
var Me=Class.extends("core.Label",Box);
Me.proto.color=null
Me.proto.stroke=null
Me.proto.fontSize=null
Me.proto.align="left"
Me.proto.middle=false
Me.proto.bold=false
Me.proto.lineH=null
Me.proto.letterSpacing=0
Me.proto.text=null
Me.proto.html=null
Me.proto.selectable=false
Me.proto.multi=false
Me.proto.ellipsis=false
Me.proto.indent=false
Me.proto.textShadow=null
Me.proto.__ctor=function(text,color,fontSize){
 this.enabled=false
 if(fontSize==null) fontSize=int(24*GAid.designW/640)
 if(this.__class==Label){
 if(is(Array,text)){
 color=text[1]
 fontSize=text[2]||fontSize
 text=text[0]
 }
 this.color=color||"#000"
 this.fontSize=fontSize
 this.text=text||""
 }
 else{
 this.color="#000"
 this.fontSize=fontSize
 this.text=""
 }
 this.lineH=(G.os==1?1:1.2)*this.fontSize
 this.div.style.cssText="color:"+G.toColor(this.color)+";font-size:"+fontSize+"px;white-space:nowrap;"
 +"pointer-events:none;"+G.toCssKey("text-size-adjust")+":100%;line-height:"+this.lineH+"px"
 this.div.innerText=this.text
 }
Me.proto.setSize=function(w,h){
 Box.proto.setSize.call(this,w,h)
 if(!this.multi&&!this.mask){
 this.div.style.minWidth=this.div.style.width
 this.div.style.width="auto"
 }
 if(this.middle) this.setMiddle(true)
 }
Me.proto.setText=function(v){
 if(!is(String,v)) v+=""
 this.text=v
 this.div.innerText=v
 if(this.middle) this.setMiddle(true)
 G.renderIos=true
 }
Me.proto.setSelectable=function(v){
 this.selectable=v
 this.div.style[G.toCssKey("UserSelect")]=v?"text":"none"
 }
Me.proto.setHtml=function(v){
 if(!is(String,v)) v+=""
 this.html=v
 this.div.innerHTML=v
 if(this.middle) this.setMiddle(true)
 G.renderIos=true
 }
Me.proto.setMiddle=function(v){
 this.middle=v
 var top=0
 if(v){
 var h=this.div.clientHeight
 var lineH=this.lineH
 if(lineH<10) lineH*=this.fontSize
 top=(lineH-h)/2
 }
 this.div.style.marginTop=top+"px"
 }
Me.proto.setColor=function(v){
 this.color=v
 this.div.style.color=G.toColor(v)
 }
Me.proto.setStroke=function(v){
 this.stroke=v
 this.div.style[G.toCssKey("TextStroke")]=!v?"none":"1px "+G.toColor(v)
 }
Me.proto.setFontSize=function(v){
 this.fontSize=v
 this.div.style.fontSize=v+"px"
 }
Me.proto.setAlign=function(v){
 if(v=="c") v="center"
 if(v=="r") v="right"
 this.align=v
 this.div.style.textAlign=v
 }
Me.proto.setBold=function(v){
 this.bold=v
 this.div.style.fontWeight=v?"bold":"normal"
 }
Me.proto.setLineH=function(v){
 if(v<10) v*=this.fontSize
 this.lineH=v
 this.div.style.lineHeight=v+"px"
 }
Me.proto.setLetterSpacing=function(v){
 this.letterSpacing=v
 this.div.style.letterSpacing=v+"px"
 }
Me.proto.setMulti=function(v){
 this.multi=v
 this.setLineH(v?1.5:(G.os==1?1:1.2))
 this.div.style.whiteSpace=!v?"nowrap":"normal"
 }
Me.proto.setIndent=function(v){
 this.indent=v
 this.div.style.textIndent=v?"2em":""
 }
Me.proto.setEllipsis=function(v){
 this.ellipsis=v
 this.mask=true
 this.div.style.overflow="hidden"
 this.div.style.whiteSpace="nowrap"
 this.div.style.textOverflow=v?"ellipsis":"clip"
 }
Me.proto.setTextShadow=function(v){
 this.textShadow=v
 var css="none"
 if(is(Array,v)){
 css=v[0]+"px "+v[1]+"px "+v[2]+"px "+G.toColor(v[3])
 }
 else{
 css="5px 5px 5px "+G.toColor(v)
 }
 this.div.style.textShadow=css
 }
})();
(function(){
var Me=Class.extends("core.RadioBox",Box);
Me.proto.index=0
Me.proto.__ctor=function(){
 this.changeSelf()
 }
Me.proto.resetSelf=function(){
 for (var i=0; i<this.children.length;i++){
 var button=this.children[i]
 button.toggleMode=true
 button.setToggled(this.index==i)
 }
 }
Me.proto.setIndex=function(v){
 this.index=v
 this.changeSelf()
 }
Me.proto.onButtonClick=function(){
 this.setIndex(G.target.getDepth())
 var target=G.target
 G.target=this
 this.dispatchEvent(G.newEvent(Evt.CHANGE))
 G.target=target
 }
})();
(function(){
var Me=Class.extends("core.Sound",null);
Me.newId=1
Me.items=[]
Me.init=function(path){
 if(path.indexOf("http")!=0) path="res/sound/"+path
 var audio
 for(var i=0;i<Me.items.length;i++){
 var audio2=Me.items[i]
 if(!audio2.playing&&audio2.path==path){
 audio=audio2
 break
 }
 }
 if(!audio){
 audio=document.createElement("audio")
 var isSupport=audio.play!=null
 if(G.isMobile&&!G.isWx) isSupport=false
 if(!isSupport){
 return
 }
 audio.src=path
 Me.items.push(audio)
 audio.path=path
 }
 audio.id=Me.newId
 Me.newId++
 audio.load()
 return audio.id
 }
Me.play=function(id,doEnd){
 var audio=Me.getAudio(id)
 if(!audio) return
 audio.doEnd=doEnd
 audio.onended=Me.onEnd
 audio.playing=true
 audio.play()
 }
Me.stop=function(id){
 var audio=Me.getAudio(id)
 if(!audio) return
 audio.playing=false
 audio.pause()
 audio.currentTime=0
 }
Me.isPlaying=function(id){
 var audio=Me.getAudio(id)
 if(!audio) return
 return audio.playing
 }
Me.getCurrentTime=function(id){
 var audio=Me.getAudio(id)
 if(!audio) return
 return audio.currentTime
 }
Me.getDuration=function(id){
 var audio=Me.getAudio(id)
 if(!audio) return
 return audio.duration
 }
Me.getAudio=function(id) {
 var audio
 for(var i=0;i<Me.items.length;i++){
 var audio2=Me.items[i]
 if(audio2.id==id){
 audio=audio2
 }
 }
 return audio
 }
Me.pauseAll=function(){
 for(var i=0;i<Me.items.length;i++){
 var audio=Me.items[i]
 if(!audio.playing) continue
 audio.pause()
 }
 }
Me.resumeAll=function(){
 for(var i=0;i<Me.items.length;i++){
 var audio=Me.items[i]
 if(!audio.playing) continue
 audio.play()
 }
 }
Me.onEnd=function(evt){
 var audio=evt.target
 audio.playing=false
 if(audio.doEnd==true){
 Sound.play(audio.path,true)
 }
 else{
 call(audio.doEnd)
 }
 }
})();
(function(){
var Me=Class.extends("core.Stage",Box);
Me.proto.__ctor=function(){
 document.body.appendChild(this.div)
 this.setMask(true)
 this.setSize(G.w,G.h)
 }
 
})();
(function(){
var Me=Class.extends("dlg.DlgAlert",Dlg);
Me.proto.button=null
 
Me.proto.body=null
Me.proto.label=null
Me.proto.doBack=null
Me.proto.__ctor=function(text,doBack){
 this.doBack=doBack
 this.addChild([
 [{dim:"body",pos:[0,0,510,250],bg:["#fff","#888",6],mask:true},
 [Class.new(Label,text),{dim:"label",pos:[40,75,430],multi:true,align:"c"}],
 [Class.new(Button,["知道了","#0b0"]),{dim:"button",pos:[0,"b","f",85],bg:["#fff",["#eee"]]}],
 ]
 ])
 var h=this.label.getClientH()
 if(h>40) this.label.setAlign("left")
 h+=220
 if(h>G.h*0.9){
 h=G.h*0.9
 this.label.set({enabled:true,mask:true,scroll:true,h:h-190})
 }
 this.body.setPos("c","c",this.body.w,h)
 this.button.setPos(0,"b")
 this.base.transit({alpha:[0,0.4],time:200})
 }
Me.proto.onClose=function(){
 this.remove()
 call(this.doBack)
 }
Me.proto.onButtonClick=function(){
 this.close()
 }
})();
(function(){
var Me=Class.extends("dlg.DlgConfirm",Dlg);
Me.proto.yesButton=null
Me.proto.noButton=null
 
Me.proto.body=null
Me.proto.label=null
Me.proto.doYes=null
Me.proto.doNo=null
Me.proto.__ctor=function(text,doYes,doNo){
 this.doYes=doYes
 this.doNo=doNo
 this.addChild([
 [{dim:"body",pos:[0,0,510,250],bg:["#fff","#888",6],mask:true},
 [Class.new(Label,text),{dim:"label",pos:[40,75,430],multi:true,align:"c"}],
 [Class.new(Button,["取消","#000"]),{dim:"noButton",pos:[0,"b","f/2",85],bg:["#fff",["#eee"]]}],
 [Class.new(Button,["确定","#0b0"]),{dim:"yesButton",pos:["r","b","f/2",85],bg:["#fff",["#eee",,"#eee"]]}],
 ]
 ])
 var h=this.label.getClientH()
 if(h>40) this.label.setAlign("left")
 h+=220
 this.body.setPos("c","c",this.body.w,h)
 this.yesButton.setPos("r","b")
 this.noButton.setPos(0,"b")
 this.base.transit({alpha:[0,0.4],time:200})
 }
Me.proto.onClose=function(){
 this.remove()
 call(this.doBack)
 }
Me.proto.onButtonClick=function(){
 this.close()
 call(G.target==this.yesButton?this.doYes:this.doNo)
 }
})();
(function(){
var Me=Class.extends("dlg.DlgList",Dlg);
Me.proto.doBack=null
Me.proto.body=null
Me.proto.__ctor=function(items,doBack){
 this.doBack=doBack
 var h=items.length*70
 if(items.length>12) h=12.5*70
 this.addChild([
 [{dim:"body",pos:["c","c",500,h+2],bg:["#fff","#eee",6],mask:true,scroll:true,relative:1}]
 ])
 for(var i=0;i<items.length;i++){
 var text=items[i]
 this.body.addChild([
 [Button,{id:i,w:"f",h:70,type:3,bg:["#fff",i==0?null:["#eee"]]},
 [[text,"#000",20],{pos:["c","c"]}]
 ]
 ])
 }
 }
Me.proto.alignLeft=function(){
 for(var i=0;i<this.body.children.length;i++){
 var button=this.body.children[i]
 var label=button.children[0]
 label.setX(40)
 }
 }
Me.proto.onButtonClick=function(){
 this.close()
 call(this.doBack,G.target.id)
 }
})();
(function(){
var Me=Class.extends("dlg.DlgPrompt",Dlg);
Me.proto.body=null
Me.proto.label=null
Me.proto.input=null
Me.proto.yesButton=null
Me.proto.noButton=null
Me.proto.doBack=null
Me.proto.__ctor=function(text,doBack){
 this.doBack=doBack
 this.addChild([
 [{dim:"body",pos:["c",200,550,250],bg:["#fff","#888",6],mask:true},
 [Class.new(Label,text),{dim:"label",pos:[30,40,490],align:"c"}],
 [Input,{dim:"input",doEnter:[this,this.onInputEnter],pos:[40,90,"f-80",45],bg:[,"#ccc",6]}],
 [Class.new(Button,["取消","#000"]),{dim:"noButton",pos:[0,"b","f/2",75],bg:["#fff",["#eee"]]}],
 [Class.new(Button,["确定","#0b0"]),{dim:"yesButton",pos:["r","b","f/2",75],bg:["#fff",["#eee",,"#eee"]]}],
 ]
 ])
 this.input.focus()
 }
Me.proto.onInputEnter=function(){
 if(!this.input.text) return
 this.close()
 call(this.doBack,this.input.text)
 }
Me.proto.onButtonClick=function(){
 switch(G.target){
 case this.yesButton:this.onInputEnter();break
 case this.noButton:this.close();break
 }
 }
})();
(function(){
var Me=Class.extends("dlg.DlgSheet",Dlg);
Me.proto.doBack=null
Me.proto.body=null
Me.proto.__ctor=function(title,items,doBack){
 if(!items) items=["知道了"]
 this.doBack=doBack
 var titleH=(title!="")?150:20
 var bodyH=items.length*110+titleH
 this.addChild([
 [{dim:"body",pos:[0,G.h,"f",bodyH],bg:"#fff"},
 {doif:(title!=null||title!="")},
 [{x:60,w:"f-120",h:titleH},
 [[title,"#666"],{pos:["c","c"],align:"c",multi:true}]
 ]
 ]
 ])
 for(var i=0;i<items.length;i++){
 var text=items[i]
 var y=titleH+i*110
 var bg=i>0&&i==items.length-1?["#aaa","#888",5]:["#B28147","#9B6F3B",5]
 this.body.addChild([
 [Class.new(Button,[text,"#fff"]),{id:i,pos:[20,y,"f-40",80],bg:bg}]
 ])
 }
 this.body.transit({y:G.h-bodyH,ease:1})
 }
Me.proto.onClose=function(){
 this.body.transit({y:G.h,ease:2},[this,this.remove])
 }
Me.proto.onButtonClick=function(){
 this.close()
 call(this.doBack,G.target.id)
 }
 
})();
(function(){
var Me=Class.extends("example.Clock",Box);

Me.proto.body=null
Me.proto.hourLine=null
Me.proto.minLine=null
Me.proto.secLine=null
 
Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.setSize("f","f")
 this.body=this.addChild({dimTo:this,pos:["c","c"],size:[500,500]})
 for(var i=0;i<60;i++){
 var w=i%15==0?12:(i%5==0?8:4)
 var h=i%15==0?32:(i%5==0?26:20)
 this.body.addChild({pos:[250,250,w,h],bg:"#000",pivot:[w/2,240],rotation:i*6})
 }
 this.body.addChild([
 [{dim:"hourLine",pos:[250,250,18,180],bg:"#000",pivot:[9,130],rotation:0}],
 [{dim:"minLine",pos:[250,250,14,230],bg:"#000",pivot:[7,180],rotation:30}],
 [{dim:"secLine",pos:[250,250,6,250],bg:"#f00",pivot:[3,200],rotation:60}],
 [{pos:[230,230,40,40],bg:["#fff","8#000",20]}]
 ])
 this.playTime()
 }
 
Me.proto.playTime=function(){
 callLater([this,this.playTime],1000)
 var d=new Date()
 var h=d.getHours()
 var m=d.getMinutes()
 var s=d.getSeconds()
 this.secLine.setRotation(360*s/60)
 this.minLine.setRotation(360*m/60)
 this.hourLine.setRotation(360*(h%12+m/60)/12)
 }
})();
(function(){
var Me=Class.extends("example.Flag",Box);

Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.set({pos:[0,0,"f","f"],relative:1,scroll:true})
 
 this.drawChina()
 this.drawAmerica()
 this.drawKorea()
 this.drawIsrael()
 this.drawCanada()
 this.drawTurkey()
 this.drawIndia()
 this.drawHongkong()
 this.drawKmt()
 }
 
Me.proto.createFlagBase=function(title,bgColor,desc){
 this.addChild([
 [[title,"#000",30],{align:"c",padding:20}],
 [[desc,"#666",20],{multi:true,padding:[,20,20,20],indent:true}],
 [{h:360,bg:"#eee"},
 [{pos:["c","c",400,270],bg:bgColor}]
 ]
 ])
 return this.children[this.children.length-1].children[0]
 }
 
Me.proto.drawChina=function(){
 var box=this.createFlagBase(
 "中国国旗",
 "#f00",
 "中华人民共和国国旗为五星红旗。长宽之比为3：2，红色旗面，左上方缀有五颗黄色五角星。一星较大，居左，四星较小，环拱于大星之右。四颗小星各有一个尖正对大星的中心点。红色象征革命，黄色寓示着红地上显出光明。五颗星及其相互关系象征中国共产党领导下的革命人民大团结。"
 )
 box.addChild([
 [{pos:[54,72,75,75],pivot:"c",bg:["#ff0",,"star"]}],
 [{pos:[122,30,25,25],pivot:"c",rotation:-30,bg:["#ff0",,"star"]}],
 [{pos:[152,58,25,25],pivot:"c",rotation:-15,bg:["#ff0",,"star"]}],
 [{pos:[152,101,25,25],pivot:"c",bg:["#ff0",,"star"]}],
 [{pos:[124,130,25,25],pivot:"c",rotation:15,bg:["#ff0",,"star"]}],
 ])
 }
 
Me.proto.drawAmerica=function(){
 var box=this.createFlagBase(
 "美国国旗",
 "#fff",
 "美利坚合众国的国旗旗面由13道红白相间的宽条构成，左上角还有一个包含了50颗白色小五角星的蓝色长方形。50颗小星代表了美国的50个州，而13条间纹则象征着美国最早建国时的13块殖民地。红色象征勇气，白色象征真理，蓝色则象征正义。这面旗帜俗称“星条旗”，正式名称“合众国旗”。它在正式成为美国国旗后曾经过28次修改。"
 )
 for(var i=0;i<7;i++){
 box.addChild([[{y:i*42,w:"f",h:21,bg:"#f00"}]])
 }
 box.addChild([[{w:192,h:147,bg:"#007"}]])
 for(var i=0;i<6;i++){
 for(var j=0;j<9;j++){
 var x=i*33+5+(j%2==0?0:18)
 var y=j*15+3
 if(j%2==1&&i>=5) continue
 box.addChild([[{pos:[x,y,17,17],bg:["#fff",,"star"]}]])
 }
 }
 }
 
Me.proto.drawKorea=function(){
 var box=this.createFlagBase(
 "韩国国旗",
 "#fff",
 "韩国国旗又称太极旗，是以儒家及道教的思想为基础而绘制的。中央的太极象征宇宙，蓝色为阴，红色为阳，万物是由阴阳所构成的；太极则是由阴阳组成，以表示宇宙调和与统一之意。4个角落的卦在左上方的是乾，右下为坤，右上为坎，左下为离，则代表天地水火、父母男女之意，也正象征民族的融合与国家的发展。国旗底色为白色，象征韩国人民的纯洁和对和平的热爱。"
 )
 box.addChild([
 [{pos:[125,60,150,150],bg:["#03e",,75]}],
 [{pos:[125,60,150,150],bg:["#f00",,"shape",[0,75],3,[150,75]]}],
 [{pos:[126,97,74,74],bg:["#f00",,37]}],
 [{pos:[200,97,74,74],bg:["#03e",,37]}],
 ])
 var arr=[
 [78,13,1],[94,25,1],[112,37,1],
 [270,42,4],[293,79,4],[287,30,3],[304,19,4],[327,56,4],
 [288,206,2],[312,168,2],[304,218,2],[329,179,2],[322,229,2],[347,191,2],
 [38,198,3],[55,186,4],[78,224,4],[72,175,3]
 ]
 for(var i=0;i<arr.length;i++){
 var a=arr[i]
 var r=a[2]<=2?32:-32
 var h=a[2]%2==1?80:36
 box.addChild([[{pos:[a[0],a[1],10,h],rotation:r,bg:"#000"}]])
 }
 }
 
Me.proto.drawIsrael=function(){
 var box=this.createFlagBase(
 "以色列国旗",
 "#fff",
 "以色列国旗呈长方形，长宽之比为11：8。白色旗面，上下各有一条蓝色宽带。白底两蓝带及蓝色“大卫之星”的旗帜。蓝白两色是犹太教僧侣披肩（塔利特）的颜色，蓝色代表以色列的天空，白色代表洁净之心。“大卫之星”是西元前十世纪以色列王国大卫王在其盾牌上的标志，代表犹太教与以色列传统文化。"
 )
 box.addChild([
 [{pos:[0,20,"f",40],bg:"#04c"}],
 [{pos:[0,"b-20","f",40],bg:"#04c"}],
 [{pos:[0,0,"f","f"],bg:[,"9#04c","shape",
 [200,82],[242,160],[156,160],[200,82],0,
 [156,108],[242,108],[200,184],[156,108]
 ]}],
 ])
 }
 
Me.proto.drawCanada=function(){
 var box=this.createFlagBase(
 "加拿大国旗",
 "#fff",
 "加拿大国旗上的枫叶代表了加拿大人对枫叶的钟爱。白色是代表国土，而加拿大有许多地方都是在北极圈内，白色代表“雪”。中间的白色代表的是加拿大广阔无垠的国土，两侧的红色代表的是东西两岸相邻的大西洋及太平洋。中间的红色枫叶则是象征生活在加拿大富饶国土上辛勤努力的人民。"
 )
 box.addChild([
 [{pos:[0,0,100,"f"],bg:"#f00"}],
 [{pos:["r",0,100,"f"],bg:"#f00"}],
 [{pos:[0,0,"f","f"],bg:["#f00",,"shape",
 [196,223],[198,181],[158,185],[163,172],
 [124,138],[134,132],[127,106],[151,110],
 [154,98],[173,120],[178,118],[170,74],[181,81],
 [185,80],[200,54],[215,80],[219,80],[229,75],
 [221,117],[226,120],[245,99],[248,110],[272,106],
 [265,133],[275,138],[236,171],[240,184],
 [201,181],[202,222],[196,223]
 ]}]
 ])
 }
 
Me.proto.drawTurkey=function(){
 var box=this.createFlagBase(
 "土耳其国旗",
 "#f00",
 "土耳其国旗呈长方形，长与宽之比为3∶2。旗面为红色，靠旗杆一侧有一弯白色新月和一颗白色五角星。红色象征鲜血和胜利；白色新月与五角星为土耳其的传统标志，也是象征伊斯兰教。弦月包星代表吉祥与幸福，象征全国人民团结及独立的意思。"
 )
 box.addChild([
 [{pos:[218,133,66,66],pivot:"c",rotation:-15,bg:["#fff",,"star"]}],
 [{pos:[0,0,"f","f"],bg:["#fff",,"shape",
 [184,92],4,[67,132],[184,175],4,[98,132],[184,92]
 ]}]
 ])
 }
 
Me.proto.drawIndia=function(){
 var box=this.createFlagBase(
 "印度国旗",
 "#fff",
 "橙色象征了勇气，献身与无私，也是印度教士法衣的颜色，白色代表了真理与和平，而绿色则代表繁荣，信心与人类的生产力。轮是印度孔雀王朝鼎盛的阿育王时代佛教圣地石柱柱头的狮首图案之一，神圣的轮象征着真理与道德，也代表了印度古老的文明。轮的24根轴条则可代表一天的24小时，象征国家时时都向前进。"
 )
 box.addChild([
 [{pos:[0,0,"f",85],bg:"#f94"}],
 [{pos:[0,"b","f",85],bg:"#6c4"}],
 [{pos:[159,94,80,80],bg:[,"5#66b",40]}],
 [{pos:[186,121,28,28],bg:[,"4#66b",14]}],
 [{pos:[194,129,12,12],bg:["#66b",,6]}],
 ])
 for(var i=0;i<18;i++){
 box.addChild([
 [{pos:[199,134,11,38],rotation:i*20,pivot:[2,36],bg:["#66b",,"shape",
 [0,0],[11,0],[11,2],4,[7,4],[4,1],[4,26],[0,26],[0,0]
 ]}]
 ])
 }
 }
 
Me.proto.drawHongkong=function(){
 var box=this.createFlagBase(
 "香港區旗",
 "#f00",
 "旗幟的底色是紅色，與中華人民共和國國旗的底色一樣，象徵香港為中華人民共和國的一部份。香港市政局標志洋紫荊圖案、花蕊以五顆星表示，再次與中華人民共和國國旗上的五星相對應，寓意中國大陸與香港密不可分的關系。區旗只用紅白兩色，象徵香港實踐一國兩制。"
 )
 for(var i=0;i<5;i++){
 box.addChild([
 [{pos:[200,133,52,90],rotation:i*72,pivot:[30,89]},
 [{pos:[0,0,"f","f"],bg:["#fff",,"shape",
 [52,1],4,[0,41],[25,88],[29,88],4,[24,72],[31,61],
 [42,50],4,[49,40],[45,24],4,[42,15],[52,1]
 ]}],
 [{pos:[0,0,"f","f"],bg:[,"2#f00","shape",[28,88],4,[15,65],[21,43]]}],
 [{pos:[26,36,18,18],pivot:"c",rotation:-30,bg:["#f00",,"star"]}],
 ]
 ])
 }
 }
 
Me.proto.drawKmt=function(){
 var box=this.createFlagBase(
 "中華民國國旗",
 "#f00",
 "中華民國國旗由青、白、紅三色組成，單就色彩而言，分別象征自由、平等、博愛之精神，以及民族、民權、民生之三民主義。若配合色彩的形狀，青天則同時又象征中華民族光明磊落、崇高偉大的人格和志氣；白日象征光明坦白、大公無私的純正心地與思想，十二道光芒形同十二個時辰，勉勵人民奮鬥精進、自強不息，芒鋒示意革命精銳，意味著民主自由光華四射；而滿地的紅色則象征革命先烈的熱血及犧牲奉獻、勇敢奮鬥的精神。"
 )
 box.addChild([
 [{pos:[0,0,200,135],bg:"#00a"}],
 [{pos:[74,40,52,52],bg:["#fff",,26]}]
 ])
 for(var i=0;i<12;i++){
 box.addChild([
 [{pos:[100,66,10,21],rotation:i*30,pivot:[6,50],bg:["#fff",,"shape",
 [5,0],[10,21],[0,21],[5,0]
 ]}]
 ])
 }
 }
})();
(function(){
var Me=Class.extends("example.FlyArrow",Box);

Me.proto.arrow=null
Me.proto.hit=null
Me.proto.toDir=2
 
Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.setSize("f","f")
 this.addChild([
 [{dim:"hit",pos:["c","c",80,80],pivot:[40,40],bg:[,"#666",40],shadow:[0,0,20,"#666",true]},
 [Class.new(Label,"Hit","#666"),{pos:["c","c"]}],
 ],
 ["example.fly-arrow",{dim:"arrow",pos:["f/2",100],rotation:-90,pivot:[0,38]}]
 ])
 this.hit.transit({alpha:[0,1],scale:[0,1],ease:1,delay:300,time:500})
 }
 
Me.proto.fly=function(m){
 if(!m){
 m={step:1}
 this.setEnabled(false)
 this.toDir++
 }
 else if(m.step==1){
 var x=this.hit.x
 var y=this.hit.y
 this.arrow.set({
 x:this.arrow.x+(x-this.arrow.x)/15,
 y:this.arrow.y+(y-this.arrow.y)/15,
 rotation:this.arrow.rotation+((this.toDir-3)*90-this.arrow.rotation)/15,
 })
 if(Math.distance(this.arrow.x,this.arrow.y,x,y)<1){
 m.step++
 m.time=G.now
 this.hit.transit({alpha:0,scale:0,ease:2})
 }
 }
 else if(m.step==2){
 if(G.now-m.time>=600){
 m.step++
 m.time=G.now
 this.setRandomPos()
 this.hit.transit({alpha:1,scale:1,ease:1})
 }
 }
 else if(m.step==3){
 if(G.now-m.time>=600){
 m.step=0
 this.setEnabled(true)
 }
 }
 if(m.step>0) callLater([this,this.fly,m],1)
 }
 
Me.proto.setRandomPos=function(){
 var x=int(G.w*(0.8*Math.random()+0.1))
 var y=int(G.h*(0.8*Math.random()+0.1))
 if(Math.distance(this.hit.x,this.hit.y,x,y)<300){
 this.setRandomPos()
 return
 }
 this.hit.setPos(x,y)
 }
 
Me.proto.onClick=function(){
 if(G.target==this.hit) this.fly()
 }
})();
(function(){
var Me=Class.extends("example.HelloWorld",Box);

Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.setSize("f","f")
 
 var label=Class.new(Label,"Hello,World","#000",80)
 this.addChild(label)
 label.setPos("c",300)
 }
})();
(function(){
var Me=Class.extends("example.Puzzle2048",Box);
Me.proto.body=null
Me.proto.map=null
Me.proto.scoreLabel=null
Me.proto.bestLabel=null
Me.proto.moveLocked=false
Me.proto.isWin=false
Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.set({pos:[0,0,"f","f"],bg:"#fff"})
 this.addChild([
 [{dim:"body",pos:["c","c+30",584,684]},
 [["2048","#666",90],{pos:["c",-120],bold:true,textShadow:"#4000"}],
 [{pos:[0,0,"f","f"],bg:["#f6f6f6","2#666",9],shadow:true}],
 [{pos:[2,2,"f-4",100],bg:["#e6e6e6",[,"#888"],[9,9]]}],
 [["BEST :","#888",30],{pos:[40,36]}],
 [["0","#444",30],{dim:"bestLabel",x:"+5"}],
 [["SCORE :","#888",30],{pos:[320,36]}],
 [["0","#444",30],{dim:"scoreLabel",x:"+5"}],
 [{dim:"map",pos:[2,102,580,580],bg:[,"#888","shape",
 [145,0],[145,580],0,[290,0],[290,580],0,[435,0],[435,580],0,
 [0,145],[580,145],0,[0,290],[580,290],0,[0,435],[580,435]
 ]}],
 ],
 ])
 this.start()
 this.playTime()
 }
Me.proto.start=function(){
 this.isWin=false
 this.bestLabel.setText(int(IO.getStorage("2048.best")))
 this.scoreLabel.setText(0)
 this.map.removeChildren()
 this.createTile(0,2)
 this.createTile(2,2)
 }
Me.proto.createTile=function(place,score){if(place==null){place=-1};if(score==null){score=2}
 if(place==-1){
 var fits=[]
 for(var y=0;y<4;y++){
 for(var x=0;x<4;x++){
 var place=y*10+x
 if(!this.getTile(place)) fits.push(place)
 }
 }
 place=fits[int(fits.length*Math.random())]
 }
 var size=score>999?40:(score>99?50:(score>9?60:80))
 var tile=this.map.addChild(Class.new(Label,score,"#888",size),0)
 tile.set({score:score,merging:false})
 tile.set({size:[120,120],lineH:120,bold:true,align:"c",pivot:"c",bg:["#fff","2#888",6]})
 this.setPlace(tile,place)
 tile.transit({scale:[0.5,1],ease:1,time:200})
 return tile
 }
Me.proto.getTile=function(place){
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(tile.score>0&&tile.place==place) return tile
 }
 return null
 }
Me.proto.setPlace=function(tile,place){
 tile.place=place
 tile.setPos((place%10)*145+72,int(place/10)*145+72)
 }
Me.proto.move=function(dir){
 var moved=false
 var js=[0,1,2,3]
 if(dir%2==0) js.reverse()
 for(var i=0;i<4;i++){
 for(var i2=0;i2<js.length;i2++){
 var j=js[i2]
 var place=dir<=2?i*10+j:j*10+i
 var tile=this.getTile(place)
 if(!tile) continue
 for(var i3=js.length-1;i3>=0;i3--){
 var n=js[i3]
 if(dir%2==1&&n>=j) continue
 if(dir%2==0&&n<=j) continue
 var place2=dir<=2?i*10+n:n*10+i
 if(!this.testMove(tile,place2)) break
 }
 if(tile.place!=place) moved=true
 }
 }
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 tile.merging=false
 }
 if(moved) this.createTile()
 this.testLose()
 }
Me.proto.testMove=function(tile,place){
 var blockTile=this.getTile(place)
 if(blockTile){
 if(blockTile.merging||blockTile.score!=tile.score) return false
 this.scoreLabel.setText(int(this.scoreLabel.text)+tile.score)
 this.bestLabel.setText(Math.max(int(this.bestLabel.text),int(this.scoreLabel.text)))
 IO.setStorage("2048.best",this.bestLabel.text)
 tile.score=0
 blockTile.score*=2
 blockTile.merging=true
 }
 this.map.addChild(tile)
 tile.transit({ease:1,time:200},[this,this.toMove,tile,blockTile])
 this.setPlace(tile,place)
 return !blockTile?true:false
 }
Me.proto.toMove=function(tile,blockTile){
 if(!blockTile) return
 tile.remove()
 var score=blockTile.score
 if(score>0){
 blockTile.setFontSize(score>999?40:(score>99?50:(score>9?60:80)))
 blockTile.setText(score)
 blockTile.transit({scale:[0.5,1],time:200})
 }
 else{
 blockTile.remove()
 }
 if(!this.isWin&&blockTile.score==2048){
 this.isWin=true
 callLater([DlgAlert,"You win!\n\nClick button to continue."],250)
 }
 }
Me.proto.testLose=function(){
 var canMerge=false
 var idleNum=16
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(tile.score==0) continue
 idleNum--
 var x=tile.place%10
 var y=int(tile.place/10)
 for(var j=0;j<this.map.children.length;j++){
 var tile2=this.map.children[j]
 if(tile2.score==0) continue
 var x2=tile2.place%10
 var y2=int(tile2.place/10)
 if(tile.score!=tile2.score) continue
 if(y2==y&&(x2==x-1||x2==x+1)) canMerge=true
 if(x2==x&&(y2==y-1||y2==y+1)) canMerge=true
 }
 }
 if(idleNum==0&&!canMerge) callLater([this,this.lose],250)
 }
Me.proto.lose=function(){
 Class.new(DlgAlert,"You lose!\n\nClick button to restart.",[this,this.start])
 }
Me.proto.playTime=function(){
 callLater([this,this.playTime])
 if(!G.main.enabled) return
 if(G.isPress){
 if(!this.moveLocked&&G.isPressMove){
 var isMoveX=Math.abs(G.x-G.pressX)>Math.abs(G.y-G.pressY)
 this.move(isMoveX?(G.x<G.pressX?1:2):(G.y<G.pressY?3:4))
 this.moveLocked=true
 }
 }
 else{
 this.moveLocked=false
 }
 }
})();
(function(){
var Me=Class.extends("example.Test",Box);
Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.setSize("f","f")
 this.playTime()
 }
Me.proto.onClick=function(){
 trace(this)
 this.remove()
 }
Me.proto.playTime=function(){
 callLater([this,this.playTime])
 trace(G.now)
 }
})();
(function(){
var Me=Class.extends("example.Tetris",Box);
Me.proto.structs=null
Me.proto.map=null
Me.proto.panel=null
Me.proto.preview=null
Me.proto.levelLabel=null
Me.proto.linesLabel=null
Me.proto.pauseButton=null
Me.proto.dir=null
Me.proto.index=null
Me.proto.index2=null
Me.proto.nextIndex=null
Me.proto.downTime=null
Me.proto.duration=300
Me.proto.pressPos=null
Me.proto.eliminates=null
Me.proto.__ctor=function(){
 this.structs=[
 [[11,12,21,22]],
 [[1,11,21,31],[10,11,12,13]],
 [[1,11,12,22],[10,11,1,2]],
 [[2,11,12,21],[12,11,1,0]],
 [[1,10,11,12],[10,21,11,1],[21,12,11,10],[12,1,11,21]],
 [[2,1,11,21],[0,10,11,12],[20,21,11,1],[22,12,11,10]],
 [[0,1,11,21],[20,10,11,12],[22,21,11,1],[2,12,11,10]],
 ]
 G.main.addChild(this)
 this.set({pos:[0,0,"f","f"],bg:"#fff"})
 this.addChild([
 [{dim:"map",pos:[0,"b",500,1000]}],
 [{dim:"panel",pos:[500,0,"f-500","f"],bg:["#e8e8e8",[,,"2#666"]]},
 [{pos:[0,120,"f",250],bg:["#d8d8d8",["2#666","2#666"]]}],
 [Button,{dim:"pauseButton",subEnabled:false,pos:[0,0,"f",120],type:3,bg:"#e8e8e8"},
 [{pos:["c-15","c",12,42],bg:"#888"}],
 [{pos:["c+15","c",12,42],bg:"#888"}],
 ],
 [{dim:"preview",y:120}],
 [["LEVEL","#888",30],{pos:[0,420,"f"],align:"c"}],
 [["1","#444",30],{dim:"levelLabel",pos:[0,470,"f"],align:"c"}],
 [["LINES","#888",30],{pos:[0,570,"f"],align:"c"}],
 [["0","#444",30],{dim:"linesLabel",pos:[0,620,"f"],align:"c"}],
 ],
 [Class.new(Label,"Pause","#fff",90),{dim:"cover",visible:false,bold:true,enabled:true,pos:[0,0,"f","f"],bg:"#6000",align:"c",lineH:G.h}]
 ])
 if(G.main.h<1000){
 var scale=G.main.h/1000
 this.map.setScaleY(scale)
 this.map.setY(0)
 }
 this.start()
 this.playTime()
 }
Me.proto.start=function(){
 this.lastDownTime=G.now
 this.nextIndex=1
 this.duration=300
 this.linesLabel.setText(0)
 this.map.removeChildren()
 this.createTile()
 }
Me.proto.createTile=function(){
 this.index=this.nextIndex
 this.index2=0
 this.nextIndex=int(Math.random()*this.structs.length)
 this.preview.removeChildren()
 var index=this.nextIndex
 var arr=this.structs[index][0]
 for(var i=0;i<arr.length;i++){
 var n=arr[i]
 var tile=this.preview.addChild({w:28,h:28,bg:["#fff","#666"]})
 tile.setPos((n%10)*30,int(n/10)*30)
 }
 var w=(index==1||index==4?3:(index==6?2:4))*30
 var h=(index>=2?3:4)*30
 this.preview.setPos((G.w-500-w)/2,(250-h)/2+120)
 
 arr=this.structs[this.index][0]
 var diff=this.index==1?0:(this.index==4?2:1)
 for(var i=0;i<arr.length;i++){
 var n=arr[i]
 var tile=this.map.addChild({w:48,h:48,bg:["#fff","#666"]})
 tile.set({index:i,place:0,toPlace:0,fixed:false})
 this.setPlace(tile,(Math.abs(int(n/10))+diff)*100+(n%10+7))
 }
 }
Me.proto.getTile=function(place){
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(tile.fixed&&tile.place==place) return tile
 }
 return null
 }
Me.proto.setPlace=function(tile,place){
 tile.place=place
 tile.setPos((place%100-4)*50,(int(place/100)-4)*50)
 }
Me.proto.move=function(dir){
 if(this.duration==0) return
 var canMove=this.testMove(dir,true)
 if(dir==2){
 if(!canMove){
 this.moveEnd()
 }
 }
 }
Me.proto.moveEnd=function(step){if(step==null){step=1}
 if(step==1){
 this.duration=0
 this.eliminates=[]
 var rowHash={}
 var isLose=false
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(!tile.fixed){
 tile.fixed=true
 tile.setBg(["#d8d8d8","#666"])
 }
 var row=int(tile.place/100)
 if(!rowHash[row]) rowHash[row]=0
 rowHash[row]++
 if(rowHash[row]==10) this.eliminates.push(row)
 if(row<4) isLose=true
 }
 if(isLose){
 Class.new(DlgAlert,"You lose!\n\nClick button to continue.",[this,this.start])
 }
 else if(this.eliminates.length==0){
 this.moveEnd(7)
 }
 else{
 this.moveEnd(2)
 }
 }
 else if(step<6){
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(this.eliminates.indexOf(int(tile.place/100))>-1){
 tile.setBg([step%2==1?"#d8d8d8":"#fff","#666"])
 }
 }
 callLater([this,this.moveEnd,step+1],200)
 }
 else if(step==6){
 for(var i=this.map.children.length-1;i>=0;i--){
 var tile=this.map.children[i]
 if(this.eliminates.indexOf(int(tile.place/100))>-1){
 tile.remove()
 }
 else{
 var row=int(tile.place/100)
 for(var j=0;j<this.eliminates.length;j++){
 if(row<this.eliminates[j]) row++
 }
 this.setPlace(tile,row*100+tile.place%100)
 }
 }
 this.moveEnd(7)
 }
 else if(step==7){
 this.linesLabel.setText(int(this.linesLabel.text)+Math.pow(this.eliminates.length,2))
 this.duration=300
 this.pressPos=null
 this.createTile()
 }
 }
Me.proto.testMove=function(dir,isDo){if(isDo==null){isDo=false}
 var canMove=true
 var toIndex2=this.index2
 if(dir==1){
 toIndex2++
 var arr=this.structs[this.index]
 if(toIndex2>=arr.length) toIndex2=0
 }
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(tile.fixed) continue
 tile.toPlace=tile.place
 if(dir==1){
 var arr=this.structs[this.index]
 var n1=arr[this.index2][tile.index]
 var n2=arr[toIndex2][tile.index]
 tile.toPlace=(int(tile.place/100)+int(n2/10)-int(n1/10))*100
 tile.toPlace+=tile.place%100+n2%10-n1%10
 }
 if(dir==2) tile.toPlace+=100
 if(dir==3) tile.toPlace-=1
 if(dir==4) tile.toPlace+=1
 if(tile.toPlace%100<4||tile.toPlace%100>=14) canMove=false
 if(int(tile.toPlace/100)>=24) canMove=false
 if(canMove&&this.getTile(tile.toPlace)) canMove=false
 if(!canMove) break
 }
 for(var i=0;i<this.map.children.length;i++){
 var tile=this.map.children[i]
 if(tile.fixed) continue
 if(canMove&&isDo){
 this.setPlace(tile,tile.toPlace)
 }
 }
 if(dir==1&&canMove) this.index2=toIndex2
 return canMove
 }
Me.proto.onPress=function(){
 this.dir=0
 if(G.target!=this.pauseButton&&G.target!=this.cover){
 this.pressPos=[G.x,G.y]
 }
 }
Me.proto.onRelease=function(){
 this.dir=0
 this.pressPos=null
 }
Me.proto.onClick=function(){
 if(G.target==this.cover){
 this.cover.transit({alpha:0},[this.cover,this.cover.setVisible,false])
 this.duration=300
 }
 else if(G.target!=this.pauseButton){
 this.move(1)
 }
 }
Me.proto.onButtonClick=function(){
 if(G.target==this.pauseButton){
 this.cover.setVisible(true)
 this.cover.transit({alpha:[0,1]})
 this.duration=0
 }
 }
Me.proto.playTime=function(){
 callLater([this,this.playTime])
 if(!G.main.enabled) return
 if(G.now-this.downTime>=this.duration){
 this.downTime=G.now
 this.move(2)
 }
 if(this.pressPos){
 var dir=0
 if(G.x<this.pressPos[0]-50) dir=3
 if(G.x>this.pressPos[0]+50) dir=4
 if(G.y>this.pressPos[1]+100) dir=2
 if(dir>0&&(this.dir==0||this.dir==dir)){
 this.dir=dir
 if(dir==2){
 this.duration=1
 }
 else{
 this.downTime+=50
 this.move(dir)
 }
 this.pressPos[0]=G.x
 this.pressPos[1]=G.y
 }
 }
 }
})();
(function(){
var Me=Class.extends("guide.ide.Ide",Box);
Me.proto.__ctor=function(){
 G.main.addChild(this)
 this.setSize("f","f")
 this.addChild([
 [IdeHead]
 ])
 }
})();
(function(){
var Me=Class.extends("guide.ide.IdeHead",Box);
Me.proto.backButton=null
Me.proto.menuButton=null
Me.proto.menuBox=null
Me.proto.__ctor=function(){
 this.set({size:["f",70],bg:["#f6f6f6",[,"#ccc"]]})
 this.addChild([
 [Button,{dim:"backButton",pos:[0,0,70,69],bg:"#f6f6f6",type:3},
 [{pos:["c","c",40,40],bg:[,["2#888"],"shape",[27,5],[10,20],[27,35]]}],
 [["我的测试"],{pos:[75,"c"]}]
 ],
 [Button,{pos:["r-70",0,70,69],bg:"#f6f6f6",type:3},
 [{pos:["c","c",40,40],bg:[,["2#888"],"shape",[9,3],[34,21],[9,39],[9,3]]}],
 ],
 [Button,{dim:"menuButton",pos:["r",0,70,70]},
 [{visible:false,pos:[0,0,"f","f"],bg:["#fff",[,,"#ccc"]]}],
 [{pos:["c","c",40,40],bg:[,["2#888"],"shape",[4,6],[36,6],0,[4,21],[36,21],0,[4,36],[36,36]]}],
 ],
 ])
 G.stage.addListener(Evt.PRESS,this,this.onStagePress)
 }
Me.proto.popMenu=function(){
 if(this.menuBox){
 this.closeMenu()
 return
 }
 this.menuButton.children[0].setVisible(true)
 var items=["外链","-","我的测试","-","新建","删除","分享"]
 var w=260
 var body=Class.new(Box)
 var y=0
 var checkIndex=2
 for(var i=0;i<items.length;i++){
 var text=items[i]
 if(text=="-"){
 var cell=body.addChild([
 [{pos:[0,y,w,20]},
 [{pos:[65,"c",175,1],bg:"#ddd"}],
 ]
 ])
 }
 else{
 cell=body.addChild([
 [Button,{id:i,name:"menuButton",type:2,pos:[0,y,w,50]},
 [{size:["f","f"]},
 {doif:checkIndex==i},
 [{pos:[12,12,24,24],bg:[,["2#444"],"shape",[2,12],[8,19],[21,2]]}],
 [[text,"#444",20],{pos:[65,"c"]}]
 ],
 [{size:["f","f"],bg:"#39f"},
 {doif:checkIndex==i},
 [{pos:[12,12,24,24],bg:[,["2#fff"],"shape",[2,12],[8,19],[21,2]]}],
 [[text,"#fff",20],{pos:[65,"c"]}]
 ],
 ]
 ])
 }
 y+=cell.h
 }
 var h=y
 this.menuBox=this.addChild({pos:["r",69,260,h+2],bg:["#fff","#ccc"],shadow:[5,5,5,"#4000"]})
 this.menuBox.addChild([
 [{pos:["r",-1,69,2],bg:"#fff"}],
 [{pos:[0,0,50,"f"],bg:[["#fff","#f0f0f0",3],[,,,"#ddd"]]}],
 [body],
 ])
 }
Me.proto.closeMenu=function(){
 if(!this.menuBox) return
 this.menuButton.children[0].setVisible(false)
 this.menuBox.remove()
 this.menuBox=null
 }
Me.proto.onStagePress=function(){
 var isInMenu=this.menuBox&&this.menuBox.contains(G.target)
 if(G.target==this.menuButton){
 this.popMenu()
 }
 else if(!isInMenu){
 this.closeMenu()
 }
 }
})();
(function(){
var Me=Class.extends("guide.main.Guide",Box);
Me.self=null
Me.items=null
 
Me.proto.body=null
Me.proto.__ctor=function(){
 GuideAid.init()
 Me.self=this
 G.stage.addChild(this)
 this.setSize("f","f")
 this.addChild([
 [{dim:"body",pos:[0,140,"f","f-150"],scroll:true,relative:1}],
 [{pos:[0,0,"f",70],bg:["#f6f6f6",[,"#ccc"]]},
 [["DreamJS","#000",30],{pos:[30,"c"]}],
 [Button,{pos:["r",0,70,69],bg:["#f6f6f6"],type:3},
 [{pos:["c","c",40,40],bg:[,["2#888"],"shape",
 [4,1],[24,1],[34,13],[34,39],[4,39],[4,1],0,[24,1],[24,13],[34,13],0
 ]}],
 ]
 ],
 [Class.new(TabBar,["实例","文档","圈子"]),{pos:[0,70]}],
 ])
 var arr=Me.items[0]
 for(var i=0;i<arr.length;i++){
 var a=arr[i]
 this.body.addChild([
 [Button,{id:i,name:"cell",w:"f",h:70,bg:["#fff",[,"#ccc"]],type:3,arrow:true},
 [[a[1]+"("+a[0]+")"],{pos:[50,"c"]}]
 ]
 ])
 }
 G.main.setY(80)
 G.main.setH(G.h-80)
 }
Me.proto.onButtonClick=function(){
 if(G.target.name=="cell"){
 Me.self.setX(G.w)
 Class.new(GuideInfo,G.target.id)
 }
 }
})();
(function(){
var Me=Class.extends("guide.main.GuideAid",null);
Me.items=[
 [
 ["第一课","HelloWorld"],
 ["国旗","Flag"],
 ["时钟","Clock"],
 ["让箭头飞","FlyArrow"],
 ["拼图2048","Puzzle2048"],
 ],
 [
 ["什么是dreamjs","syntax"],
 ["准备开发环境","dev"],
 ],
 
 ]
Me.init=function(){
 Guide.items=Me.items
 }
})();
(function(){
var Me=Class.extends("guide.main.GuideInfo",Box);
Me.proto.codeBox=null
Me.proto.codeButton=null
Me.proto.tabBar=null
Me.proto.fileName=null
Me.proto.__ctor=function(index){
 if(!Guide.items) GuideAid.init()
 G.stage.addChild(this)
 this.setSize("f","f")
 
 var itemArr=Guide.items[0][index]
 this.fileName=itemArr[1]
 this.addChild([
 [{dim:"codeBox",enabled:true,scroll:true,relative:1,visible:false,pos:[0,70,"f","f-80"],bg:"#fff"}],
 [{pos:[0,0,"f",70],bg:["#fff",[,"#ccc"]],shadow:[0,0,5,"#3000"]},
 [Button,{name:"close",pos:[0,0,70,"f"],bg:[,[,,,"#ccc"]],type:3},
 [{pos:["c","c",22,40],bg:[,"2#888","shape",[22,0],[2,20],[22,40]]}]
 ],
 [RadioBox,{dim:"tabBar",pos:[70,0,"f-140","f"]},
 [Class.new(Button,[itemArr[0],"#000",22]),{name:"effect",bg:["#fff",[,,,"#ccc"]],pos:[0,0,"f/2","f"]}],
 [Class.new(Button,[itemArr[1],"#000",22]),{dim:"codeButton",name:"code",bg:["#fff",[,,,"#ccc"]],pos:["+",0,"f/2","f"]}],
 ],
 [Button,{name:"all",pos:["r",0,70,"f"],bg:[,[,,,"#ccc"]],type:3},
 [{enabled:false,pos:["c","c",40,30],bg:[,"2#888","shape",[0,1],[40,1],0,[0,15],[40,15],0,[0,29],[40,29]]}]
 ],
 ],
 ])
 this.codeBox.div.style.cssText+="padding:10px;"+G.toCssKey("user-select")+":text;font-size:20px"
 var classObj=window[this.fileName]
 Class.new(classObj)
 this.setH(80)
 }
Me.proto.showEffect=function(){
 G.main.setEnabled(true)
 this.codeBox.setVisible(false)
 this.setH(80)
 this.codeButton.setText(this.fileName)
 }
Me.proto.showCode=function(fileName){
 G.main.setEnabled(false)
 this.codeBox.setVisible(true)
 this.codeBox.removeChildren()
 this.setH("f")
 var classObj=window[fileName]
 var path="code/"+classObj.__classPath.replace(/\./g,"/")+".js"
 var code=IO.readFile(path).replace(/\r/g,"")
 var arr=code.split("\n")
 var html=""
 for(var i=0;i<arr.length;i++){
 var str=arr[i]
 if(str.indexOf("//")==0){
 for(var j=i+1;j<arr.length;j++){
 var str2=arr[j]
 if(str2.indexOf("//")!=0) break
 str+="\\n"+str2.slice(2)
 i=j
 }
 }
 html+=this.getRowHtml(str)
 }
 this.codeBox.div.innerHTML=html
 }
Me.proto.openAll=function(){
 var items=[]
 for(var i=0;i<Class.items.length;i++){
 var classObj=Class.items[i]
 var path=classObj.__classPath
 path=path.replace(/\./g,"/")+".js"
 items.push(path)
 }
 items.sort()
 var dlg=Class.new(DlgList,items,[this,this.toOpenAll,items])
 G.stage.addChild(dlg)
 dlg.alignLeft()
 }
Me.proto.toOpenAll=function(index,items){
 var path=items[index]
 var fileName=path.slice(0,-3).replace(/[^\/]+\//g,"")
 this.showCode(fileName)
 this.codeBox.div.scrollTop=0
 this.codeButton.setText(fileName)
 this.tabBar.setIndex(1)
 }
Me.proto.getRowHtml=function(rowStr){
 var keys=["Class","class","extends","var","public","static","function","for","this","if","else","elseif","continue","break","return","while","switch","case","delete","null","true","false","super","each","new"]
 if(rowStr.indexOf("//")==0){
 var str=""
 var a=rowStr.slice(2).split("\\n")
 for(var i=0;i<a.length;i++){
 var s=a[i]
 if(s.indexOf("<")==0){
 str+="<img src='"+s.slice(1,-1)+"'><br>"
 }
 else{
 str+="<p style='text-indent:"+(a.length==1?0:2)+"em;margin:0px'><font style='font-size:0px'>//#</font>"+s+"</p>"
 }
 }
 return "<div style='font-size:20px;margin:10px;padding:10px;display:block;background:#f6f6f6;border:1px solid #c0c0c0;"+G.toCssKey("border-radius")+":6px'>"+str+"</div>"
 }
 
 if(rowStr=="") rowStr=" "
 var html=""
 var tabSize=0
 while(true){
 var s=rowStr.charAt(0)
 if(s!=" "&&s!="\t") break
 tabSize+=s=="\t"?4:1
 rowStr=rowStr.slice(1)
 }
 var str=""
 for(var i=0;i<tabSize;i++){
 str+="&nbsp;"
 }
 if(str) html+="<font style='font-size:0px'>"+str+"</font>"
 for(var i=0;i<rowStr.length;i++){
 var s=rowStr.charAt(i)
 var s2=rowStr.charAt(i+1)
 if(s=="\""||s=="'"){
 for(var j=i+1;j<rowStr.length;j++){
 var sj=rowStr.charAt(j)
 if(rowStr.charAt(j-1)!="\\"&&sj==s) break
 }
 var str=rowStr.slice(i,j+1)
 i=j
 html+="<font color='#008000'>"+str+"</font>"
 }
 else if(s=="/"&&s2=="/"){
 for(var j=i+1;j<rowStr.length;j++){
 var sj=rowStr.charAt(j)
 }
 var str=rowStr.slice(i,j+1)
 i=j-1
 html+="<font color='#606060'>"+str+"</font>"
 }
 else if(s=="/"){
 for(var j=i+1;j<rowStr.length;j++){
 var sj=rowStr.charAt(j)
 if(rowStr.charAt(j-1)!="\\"&&sj=="/") break
 }
 var str=rowStr.slice(i,j+1)
 i=j
 html+=str
 
 }
 else if(this.isLetter(s)){
 for(var j=i+1;j<rowStr.length;j++){
 var sj=rowStr.charAt(j)
 if(!this.isLetter(sj)&&!this.isNumber(sj)) break
 }
 var str=rowStr.slice(i,j)
 i=j-1
 var c=s.charCodeAt(0)
 if(keys.indexOf(str)>-1){
 html+="<font color='#2020ff'>"+str+"</font>"
 }
 else if(c>=65&&c<=90){
 html+="<font color='#0080aa'>"+str+"</font>"
 }
 else{
 html+=str
 }
 }
 else if(this.isNumber(s)){
 for(var j=i+1;j<rowStr.length;j++){
 var sj=rowStr.charAt(j)
 if(sj!="."&&!this.isNumber(sj)) break
 }
 var str=rowStr.slice(i,j)
 i=j-1
 html+="<font color='#d00000'>"+str+"</font>"
 }
 else{
 if(s==" ") s="&nbsp;"
 if(s=="<") s="&lt;"
 html+=s
 }
 }
 return "<div style='text-indent:-40px;word-wrap:break-word;line-height:120%;padding-left:"+(tabSize*10+40)+"px'>"+html+"</div>"
 }
Me.proto.isLetter=function(s){
 var c=s.charCodeAt(0)
 return s=="_"||(c>=65&&c<=90)||(c>=97&&c<=122)
 }
Me.proto.isNumber=function(s){
 var c=s.charCodeAt(0)
 return c>=48&&c<=57
 }
Me.proto.onRemove=function(){
 G.main.setEnabled(true)
 G.main.removeChildren()
 if(Guide.self) Guide.self.setX(0)
 }
Me.proto.onButtonClick=function(){
 switch(G.target.name){
 case "close":this.remove();break
 case "effect":this.showEffect();break
 case "code":this.showCode(this.fileName);break
 case "all":this.openAll();break
 }
 }
})();
GAid.params=[]